Java Reference
In-Depth Information
does the rest. Very convenient! So convenient, in fact, that Mailer is part of the
com.darwinsys.util package.
For extra generality, the lists of To, CC, and BCC recipients can be set in one of three ways:
▪ By passing a string containing one or more recipients, such as “ian, robin”
▪ By passing a List containing all the recipients as strings
▪ By adding each recipient as a string
A “full” version allows the user to type the recipients, the subject, the text, and so on into a
GUI and have some control over the header fields. The MailComposeBean (in Program:
MailClient ) does all of these, using a Swing-based GUI. MailComposeBean uses this Mailer
class to interface with the JavaMail API. Example 17-4 contains the code for the Mailer
class.
Example 17-4. Mailer.java
package
package com . darwinsys . mail ;
public
public class
Mailer {
/** The javamail session object. */
protected
class Mailer
protected Session session ;
/** The sender's email address */
protected
protected String from ;
/** The subject of the message. */
protected
protected String subject ;
/** The recipient ("To:"), as Strings. */
protected
protected List < String > toList = new
new ArrayList <>();
/** The CC list, as Strings. */
protected
protected List < String > ccList = new
new ArrayList < String >();
/** The BCC list, as Strings. */
protected
protected List < String > bccList = new
new ArrayList < String >();
/** The text of the message. */
protected
protected String body ;
/** The SMTP relay host */
protected
protected String mailHost ;
/** The verbosity setting */
protected
protected boolean
boolean verbose ;
/** Get from */
public
public String getFrom () {
return
return from ;
}
Search WWH ::




Custom Search