Here is a chunk of my code. attachmentList is a HashTable of Strings (filenames)
if( attachmentList.isEmpty() )
{
try
{
message.setText(messageBody.toString());
}
catch( MessagingException me )
{
return MESSAGE_CREATE_FAIL_BODY;
}
}
else
{
DataSource source;
String filename;
BodyPart messageBodyPart = new MimeBodyPart();
Multipart multipart = new MimeMultipart();
try
{
messageBodyPart.setText(messageBody.toString()); //add the message to
the first body part
multipart.addBodyPart(messageBodyPart);
}
catch( MessagingException me )
{
return MESSAGE_CREATE_FAIL_BODY;
}
try
{
for (Enumeration e = attachmentList.elements() ; e.hasMoreElements()
;)
{
filename = e.nextElement().toString();
messageBodyPart = new MimeBodyPart();
source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
}
message.setContent(multipart);
}
catch( MessagingException me )
{
return MESSAGE_CREATE_FAIL_ATTACHMENT;
}
}
attachmentList contains multiple file names, but only the last file is attached to the
email. Can someone shed some light here?
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________