Recall that for each contact we are saving three pieces of information: a name, an
address, and a note. Therefore, when we read in the address book, we??™ll have three elements in
our Properties object for each contact. To get the total number of contacts then, we need to
divide by 3.
MailSender.java
Now we come to the home stretch: the last three classes we need to look at: MailSender,
MailRetriever, and MailDeleter. Clearly these are the classes that will do the majority of the
work in InstaMail. After all, it is a mail client, and these classes clearly are working with mail
messages, so let??™s jump right in to MailSender, as shown in Listing 4-5 and the UML diagram
in Figure 4-11.
CHAPTER 4 n INSTAMAIL: AN AJAX-BASED WEBMAIL CLIENT 173
Listing 4-5. The MailSender Class Code
package com.apress.dwrprojects.instamail;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.mail.Session;
import javax.mail.Message;
import java.util.Date;
import java.text.SimpleDateFormat;
import javax.mail.internet.MimeMessage;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import javax.mail.Transport;
import javax.
Pages:
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330