public static void main(String[] args)
{
String strBaseFolder = "D:\\Data\\Aspose\\resources\\";
System.out.println("Creating new messages....");
// Create a new instance of MailMessage class
MailMessage message = new MailMessage();
// Set sender information
message.setFrom(new MailAddress("from@domain.com", "Sender Name", false));
// Add recipients
message.getTo().add(new MailAddress("to1@domain.com", "Recipient 1", false));
message.getTo().add(new MailAddress("to2@domain.com", "Recipient 2", false));
// Set subject of the message
message.setSubject("New message created by Aspose.Email for Java");
// Set Html body
message.setHtmlBody("This line is in bold. <br/> <br/>" +
"<font color=blue>This line is in blue color</font>");
// Save message in EML, MSG and MHTML formats
message.save(strBaseFolder + "Message.eml", MailMessageSaveType.getEmlFormat());
message.save(strBaseFolder + "Message.msg", MailMessageSaveType.getOutlookMessageFormat());
message.save(strBaseFolder + "Message.mhtml", MailMessageSaveType.getMHtmlFromat());
System.out.println("Messages created successfuly");
}
Please use Aspose.Email for Java:
http://www.aspose.com/java/email-component.aspx for this code. Thanks