Java Reference
In-Depth Information
int msgNum = msgs.length;
while(processMessage(msgs[--msgNum]));
The processMessage() method does the actual message processing. Note that messages are
processed in reverse order until the processMessage() method returns false . I do this for the
eminently practical reason that I am more interested in recent messages and do not want to loop
through the hundreds of messages on my e-mail server.
The processMessage() method parses out the date, subject, and sender information for display to
the console. It then checks the date against today's date, returning false if the message is more than
three days old.
If the MIME content type of the message is text or HTML, the message is saved as a Clob to a simple
E-mail Table. The table includes columns for the following items:
 
Date
 
Sender
 
Sender E-mail Address
 
Subject
 
Mime Type
 
Content
Note that the individual parts of a single message are saved as separate rows, so a message may be
saved over more than one row. Using an automatically incremented message id in the table helps
identify message parts separately, as does the Mime-type field.
Summary
This chapter provided an overview of the JavaMail API. Specific topics discussed were:
 
Developing e-mail applications using the JavaMail API
 
Sending e-mails from database-driven applications by using JavaMail
 
Receiving e-mails by using the JavaMail API and saving them to a database
This chapter concludes Part III , in which the JDBC Extension API has been discussed in the context of
Web applications. Part IV focuses on using Java databases with XML.
Search WWH ::




Custom Search