Setting the message headers |
The EmailMessage class comes with a set of convenience methods and constructors that allow you to easily define common headers such as Subject, To address, From address and others.
To create an email message with the From and To and Subject headers defined use the EmailMessage constructor which takes two String arguments.
Example
// creates email message with From and To headers defined EmailMessage msg = new EmailMessage("from@domain.com","to@domain.com");
Other headers of the email message may be set using convenience methods found in the EmailMessage class or by using the EmailMessage#addHeader method which takes a com.jscape.inet.mime.MimeHeader argument.
Example
// create X-Mailer header with value of JSCAPE MimeHeader xm = new MimeHeader("X-Mailer","JSCAPE");
// create new email message EmailMessage msg = new EmailMessage();
// add header to email message msg.addHeader(xm);
See also
Setting the message headers using non US-ASCII data |