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]

