If anyone else is interested in this question...
I found out that the smtp protocol (sun.net.smtp.SmtpClient)is one way to send mail through
Java without using Java Mail API.
But the Smtp API does not seeem to support attachments.
public class sun.net.smtp.SmtpClient
extends sun.net.TransferProtocolClient {
public void closeServer()
throws IOException;
public void to(
String)
throws IOException;
public void from(String)
throws IOException;
public PrintStream startMessage()
throws IOException;
public sun.net.smtp.SmtpClient(String)
throws IOException;
public sun.net.smtp.SmtpClient()
throws IOException;
public String getMailHost();
}
I found a great example that uses Java Mail to send an attachment.
// create mime message object
// set the required parameters
MimeMessage message = createMessage(to, cc, subject);
// create the message part
MimeBodyPart messageBodyPart = new MimeBodyPart();
//fill message
messageBodyPart.setText(msg);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// fill the array of files to be attached
File [] attachments = {
new File("x.txt"),
new File("y.htm"),
new File("z.jpg")
};
for( int i = 0; i < attachments.length; i++ )
{
messageBodyPart = new MimeBodyPart();
FileDataSource fileDataSource =new FileDataSource(
attachments[i]);
messageBodyPart.setDataHandler(new DataHandler(
fileDataSource));
messageBodyPart.setFileName(
attachments[i].getName());
multipart.addBodyPart(messageBodyPart);
}
// add the Multipart to the message
message.setContent(multipart);
// SEND THE MESSAGE
Transport.send( message );