Java Reference
In-Depth Information
Figure 2-1. A simple GUI mail program
The mail code is all tied up in the actionPerformed() method and looks very similar
to the main() method of Example 2-1 . It is activated when the user presses the “Send
Message” button. The big difference is that now the host, username, password, subject,
From: address, To: address, and text of the message are all read from the GUI compo‐
nents at runtime rather than being hardcoded as string literals in the source code. The
rest of the code is related to setting up the GUI and has little to do with the JavaMail
API.
Example 2-2. A graphical SMTP client
import javax.mail.* ;
import javax.mail.internet.* ;
import java.util.* ;
import javax.swing.* ;
 
Search WWH ::




Custom Search