How to display attachments like gif in web based mail?

Good day everyone.My problem is displaying attachments of known types(like jpeg,gif, etc.) into a web based mail? If you can provide code snippets the better, thanks...
[189 byte] By [MLomongo] at [2007-9-26 3:53:56]
# 1

Once you install JavaMail, there is an example called SimpleClient in the folder %JAVAMAIL_HOME%/demo/client

I think that example should have all you need.

See the file %JAVAMAIL_HOME%/demo/client/README.txt to get to know about compiling the example and what the example contains.

neville_sequeira at 2007-6-29 12:42:37 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

NOTE: This is taken virtually verbatim from the sendfile.java example included with the JavaMail API.

All credit for the code belongs to Christopher Cotton and Sun Microsystems!

That said...

Assuming you've already created a MimeMessage object named msg and a String filename (and set recipient, subject, etc...):

MimeBodyPart mbp1 = new MimeBodyPart();

mbp1.setText("Here's your attached file!");

MimeBodyPart mbp2 = new MimeBodyPart();

FileDataSource fds = new FileDataSource(filename);

mbp2.setDataHandler(new DataHandler(fds));

mbp2.setFileName(fds.getName());

Multipart mp = new MimeMultipart();

mp.addBodyPart(mbp1);

mp.addBodyPart(mbp2);

msg.setContent(mp);

...

NOTE: This is taken virtually verbatim from the sendfile.java example included with the JavaMail API.

All credit for the code belongs to Christopher Cotton and Sun Microsystems!

ddwb at 2007-6-29 12:42:37 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...