Need Help on Sending Multiple Attachments

[nobr]Hi to all,

I hope some one will help me.. Im stuck with this one. I can only send one attachment.

Is there someone who know how to send an mail with 2 or more attachments?

My code is below, I followed this code from the toturial:

Hope for a kind reply. :-)

Thankz..

MimeMessage myMessage =new MimeMessage(s);

InternetAddress fromRec =new InternetAddress(strFrom);

myMessage.setFrom(fromRec);

Address[] toAddress = InternetAddress.parse(strTo);

myMessage.addRecipients(Message.RecipientType.TO, toAddress );

Address[] toCC = InternetAddress.parse(strCC);

myMessage.addRecipients(Message.RecipientType.CC, toCC );

Address[] toBCC = InternetAddress.parse(strBCC);

myMessage.addRecipients(Message.RecipientType.BCC, toBCC );

myMessage.setSubject( strSubject );

MimeBodyPart messageBodyPart =new MimeBodyPart();

messageBodyPart.setContent(strMessage +"<BR>" +URLResponse ,"text/html" );

Multipart multipart =new MimeMultipart();

multipart.addBodyPart(messageBodyPart);

/*Part two is attachment*/

messageBodyPart =new MimeBodyPart();

DataSource source =new FileDataSource( fileRepository);

messageBodyPart.setDataHandler(new DataHandler(source));

messageBodyPart.setFileName(fileName);

multipart.addBodyPart(messageBodyPart);

/* Put parts in message*/

myMessage.setContent(multipart);

/* End */

Transport.send(myMessage);

[/nobr]

[1906 byte] By [Christopher_Keith] at [2007-11-26 12:15:57]
# 1
Your code is only adding one attachment. Just repeat the codethat adds an attachment to add more than one.
bshannon at 2007-7-7 14:51:21 > top of Java-index,Archived Forums,Socket Programming...
# 2
Just repeat the potion of the code where you do the attaching
khookh at 2007-7-7 14:51:21 > top of Java-index,Archived Forums,Socket Programming...