Its absoluetly not necessary to use any packages outside of the JavaMail API, I would not use anything from oreilly or anyone else. Why do it when JavaMail gives you what you need?
Example below....obviously needs to be rounded out
//create a MimeMultiPart
MimeMultipart aMimeMultipart = new MimeMultipart();
//add any inline data, i.e. "Hi Bob, here are some files"
MimeBodyPart anInlineBodyPart = new MimeBodyPart();
anInlineBodyPart.setContent(someString, "text/plain");
anInlineBodyPart.setDisposition("INLINE");
aMimeMultipart.addBodyPart(anInlineBodyPart);
//loop thru and add your attachments
for(int ctr = 0; ctr < numberOfFiles; ctr++)
{
aFileBodyPart.setContent(someString, myContentType);
aFileBodyPart.setDisposition("ATTACHMENT");
}
aMimeMultipart.addBodyPart(aMimeBodyPart);
//set the content of the MimeMessage with your multipart
MimeMessage aMimeMessage = new MimeMessage(mySession);
aMimeMessage.setContent(aMimeMultipart);
The eone caveat is you may need to write a content handler for the data. If you dont want to do this, then you can use a DataSource to add a file directly. But the assumption I made above is that you have the raw data in memeory already. Writing data sources and content handlers is easy. Here is an example:
import java.io.*;
import javax.activation.*;
public class MyDataSource implements DataSource
{
public MyDataSource(byte[] bb,
String contentType)
{
super();
this.bb = bb;
this.contentType = contentType;
}
public String getName()
{
return getClass().getName();
}
public String getContentType()
{
return contentType;
}
public InputStream getInputStream() throws IOException
{
return new ByteArrayInputStream(bb);
}
public OutputStream getOutputStream()
{
return null;
}
protected byte[] bb;
protected String contentType;
}
if you need more clarification, just ask!!!