KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JavaMailServlet


1 /*
2  * @(#)JavaMailServlet.java 1.5 01/05/23
3  *
4  * Copyright 1998, 1999 Sun Microsystems, Inc. All Rights Reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * - Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * - Redistribution in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * Neither the name of Sun Microsystems, Inc. or the names of contributors
18  * may be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * This software is provided "AS IS," without a warranty of any kind. ALL
22  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
23  * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
24  * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND
25  * ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES
26  * SUFFERED BY LICENSEE AS A RESULT OF OR RELATING TO USE, MODIFICATION
27  * OR DISTRIBUTION OF THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
28  * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
29  * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
30  * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
31  * ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS
32  * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
33  *
34  * You acknowledge that Software is not designed, licensed or intended
35  * for use in the design, construction, operation or maintenance of any
36  * nuclear facility.
37  */

38
39 import java.io.*;
40 import java.util.*;
41 import java.text.*;
42
43 import javax.servlet.*;
44 import javax.servlet.http.*;
45 import javax.mail.*;
46 import javax.mail.internet.*;
47 import javax.activation.*;
48
49
50 /**
51  * This is a servlet that demonstrates the use of JavaMail APIs
52  * in a 3-tier application. It allows the user to login to an
53  * IMAP store, list all the messages in the INBOX folder, view
54  * selected messages, compose and send a message, and logout.
55  * <p>
56  * Please note: This is NOT an example of how to write servlets!
57  * This is simply to show that JavaMail can be used in a servlet.
58  * <p>
59  * For more information on this servlet, see the
60  * JavaMailServlet.README.txt file.
61  * <p>
62  * For more information on servlets, see
63  * <a HREF="http://java.sun.com/products/java-server/servlets/index.html">
64  * http://java.sun.com/products/java-server/servlets/index.html</a>
65  *
66  * @author Max Spivak
67  */

68 public class JavaMailServlet extends HttpServlet implements SingleThreadModel {
69     String JavaDoc protocol = "imap";
70     String JavaDoc mbox = "INBOX";
71
72
73     /**
74      * This method handles the "POST" submission from two forms: the
75      * login form and the message compose form. The login form has the
76      * following parameters: <code>hostname</code>, <code>username</code>,
77      * and <code>password</code>. The <code>send</code> parameter denotes
78      * that the method is processing the compose form submission.
79      */

80     public void doPost(HttpServletRequest req, HttpServletResponse res)
81     throws ServletException, IOException {
82
83         // get the session
84
HttpSession ssn = req.getSession(true);
85
86     String JavaDoc send = req.getParameter("send");
87         String JavaDoc host = req.getParameter("hostname");
88         String JavaDoc user = req.getParameter("username");
89         String JavaDoc passwd = req.getParameter("password");
90         URLName url = new URLName(protocol, host, -1, mbox, user, passwd);
91
92         ServletOutputStream out = res.getOutputStream();
93     res.setContentType("text/html");
94     out.println("<html><body bgcolor=\"#CCCCFF\">");
95
96     if (send != null) {
97         // process message sending
98
send(req, res, out, ssn);
99
100     } else {
101         // initial login
102

103         // create
104
MailUserData mud = new MailUserData(url);
105         ssn.putValue("javamailservlet", mud);
106         
107         try {
108         Properties props = System.getProperties();
109         props.put("mail.smtp.host", host);
110         Session session = Session.getDefaultInstance(props, null);
111         session.setDebug(false);
112         Store store = session.getStore(url);
113         store.connect();
114         Folder folder = store.getDefaultFolder();
115         if (folder == null)
116             throw new MessagingException("No default folder");
117         
118         folder = folder.getFolder(mbox);
119         if (folder == null)
120             throw new MessagingException("Invalid folder");
121         
122         folder.open(Folder.READ_WRITE);
123         int totalMessages = folder.getMessageCount();
124         Message[] msgs = folder.getMessages();
125         FetchProfile fp = new FetchProfile();
126         fp.add(FetchProfile.Item.ENVELOPE);
127         folder.fetch(msgs, fp);
128         
129         // track who logged in
130
System.out.println("Login from: " + store.getURLName());
131         
132         // save stuff into MUD
133
mud.setSession(session);
134         mud.setStore(store);
135         mud.setFolder(folder);
136         
137         // splash
138
out.print("<center>");
139         out.print("<font face=\"Arial,Helvetica\" font size=+3>");
140         out.println("<b>Welcome to JavaMail!</b></font></center><p>");
141
142         // folder table
143
out.println("<table width=\"50%\" border=0 align=center>");
144         // folder name column header
145
out.print("<tr><td width=\"75%\" bgcolor=\"#ffffcc\">");
146         out.print("<font face=\"Arial,Helvetica\" font size=-1>");
147         out.println("<b>FolderName</b></font></td><br>");
148         // msg count column header
149
out.print("<td width=\"25%\" bgcolor=\"#ffffcc\">");
150         out.print("<font face=\"Arial,Helvetica\" font size=-1>");
151         out.println("<b>Messages</b></font></td><br>");
152         out.println("</tr>");
153         // folder name
154
out.print("<tr><td width=\"75%\" bgcolor=\"#ffffff\">");
155         out.print("<a HREF=\"" + HttpUtils.getRequestURL(req) + "\">" +
156               "Inbox" + "</a></td><br>");
157         // msg count
158
out.println("<td width=\"25%\" bgcolor=\"#ffffff\">" +
159                 totalMessages + "</td>");
160         out.println("</tr>");
161         out.println("</table");
162         } catch (Exception JavaDoc ex) {
163         out.println(ex.toString());
164         } finally {
165         out.println("</body></html>");
166         out.close();
167         }
168     }
169     }
170
171
172     /**
173      * This method handles the GET requests for the client.
174      */

175     public void doGet (HttpServletRequest req, HttpServletResponse res)
176     throws ServletException, IOException {
177
178         HttpSession ses = req.getSession(false); // before we write to out
179
ServletOutputStream out = res.getOutputStream();
180     MailUserData mud = getMUD(ses);
181
182     if (mud == null) {
183         res.setContentType("text/html");
184         out.println("<html><body>Please Login (no session)</body></html>");
185         out.close();
186         return;
187     }
188
189     if (!mud.getStore().isConnected()) {
190         res.setContentType("text/html");
191         out.println("<html><body>Not Connected To Store</body></html>");
192         out.close();
193         return;
194     }
195
196
197     // mux that takes a GET request, based on parameters figures
198
// out what it should do, and routes it to the
199
// appropriate method
200

201     // get url parameters
202
String JavaDoc msgStr = req.getParameter("message");
203         String JavaDoc logout = req.getParameter("logout");
204     String JavaDoc compose = req.getParameter("compose");
205     String JavaDoc part = req.getParameter("part");
206     int msgNum = -1;
207     int partNum = -1;
208
209     // process url params
210
if (msgStr != null) {
211         // operate on message "msgStr"
212
msgNum = Integer.parseInt(msgStr);
213
214         if (part == null) {
215         // display message "msgStr"
216
res.setContentType("text/html");
217         displayMessage(mud, req, out, msgNum);
218
219         } else if (part != null) {
220         // display part "part" in message "msgStr"
221
partNum = Integer.parseInt(part);
222                 displayPart(mud, msgNum, partNum, out, res);
223         }
224
225     } else if (compose != null) {
226         // display compose form
227
compose(mud, res, out);
228
229         } else if (logout != null) {
230         // process logout
231
try {
232                 mud.getFolder().close(false);
233                 mud.getStore().close();
234         ses.invalidate();
235                 out.println("<html><body>Logged out OK</body></html>");
236             } catch (MessagingException mex) {
237                 out.println(mex.toString());
238             }
239
240     } else {
241         // display headers
242
displayHeaders(mud, req, out);
243     }
244     }
245
246     /* main method to display messages */
247     private void displayMessage(MailUserData mud, HttpServletRequest req,
248                 ServletOutputStream out, int msgNum)
249     throws IOException {
250         
251     out.println("<html>");
252         out.println("<HEAD><TITLE>JavaMail Servlet</TITLE></HEAD>");
253     out.println("<BODY bgcolor=\"#ccccff\">");
254     out.print("<center><font face=\"Arial,Helvetica\" ");
255     out.println("font size=\"+3\"><b>");
256     out.println("Message " + (msgNum+1) + " in folder " +
257             mud.getStore().getURLName() +
258             "/INBOX</b></font></center><p>");
259
260     try {
261         Message msg = mud.getFolder().getMessage(msgNum);
262
263         // first, display this message's headers
264
displayMessageHeaders(mud, msg, out);
265
266         // and now, handle the content
267
Object JavaDoc o = msg.getContent();
268             
269         //if (o instanceof String) {
270
if (msg.isMimeType("text/plain")) {
271         out.println("<pre>");
272         out.println((String JavaDoc)o);
273         out.println("</pre>");
274         //} else if (o instanceof Multipart){
275
} else if (msg.isMimeType("multipart/*")) {
276         Multipart mp = (Multipart)o;
277         int cnt = mp.getCount();
278         for (int i = 0; i < cnt; i++) {
279             displayPart(mud, msgNum, mp.getBodyPart(i), i, req, out);
280         }
281         } else {
282         out.println(msg.getContentType());
283         }
284
285     } catch (MessagingException mex) {
286         out.println(mex.toString());
287     }
288
289     out.println("</BODY></html>");
290     out.close();
291     }
292
293     /**
294      * This method displays a message part. <code>text/plain</code>
295      * content parts are displayed inline. For all other parts,
296      * a URL is generated and displayed; clicking on the URL
297      * brings up the part in a separate page.
298      */

299     private void displayPart(MailUserData mud, int msgNum, Part part,
300                  int partNum, HttpServletRequest req,
301                  ServletOutputStream out)
302     throws IOException {
303
304     if (partNum != 0)
305         out.println("<p><hr>");
306
307         try {
308
309         String JavaDoc sct = part.getContentType();
310         if (sct == null) {
311         out.println("invalid part");
312         return;
313         }
314         ContentType ct = new ContentType(sct);
315         
316         if (partNum != 0)
317         out.println("<b>Attachment Type:</b> " +
318                 ct.getBaseType() + "<br>");
319
320         if (ct.match("text/plain")) {
321         // display text/plain inline
322
out.println("<pre>");
323         out.println((String JavaDoc)part.getContent());
324         out.println("</pre>");
325
326         } else {
327         // generate a url for this part
328
String JavaDoc s;
329         if ((s = part.getFileName()) != null)
330             out.println("<b>Filename:</b> " + s + "<br>");
331         s = null;
332         if ((s = part.getDescription()) != null)
333             out.println("<b>Description:</b> " + s + "<br>");
334         
335         out.println("<a HREF=\"" +
336                 HttpUtils.getRequestURL(req) +
337                 "?message=" +
338                 msgNum + "&part=" +
339                 partNum + "\">Display Attachment</a>");
340         }
341     } catch (MessagingException mex) {
342         out.println(mex.toString());
343     }
344     }
345
346     /**
347      * This method gets the stream from for a given msg part and
348      * pushes it out to the browser with the correct content type.
349      * Used to display attachments and relies on the browser's
350      * content handling capabilities.
351      */

352     private void displayPart(MailUserData mud, int msgNum,
353                  int partNum, ServletOutputStream out,
354                  HttpServletResponse res)
355     throws IOException {
356
357     Part part = null;
358     
359         try {
360         Message msg = mud.getFolder().getMessage(msgNum);
361
362         Multipart mp = (Multipart)msg.getContent();
363         part = mp.getBodyPart(partNum);
364         
365         String JavaDoc sct = part.getContentType();
366         if (sct == null) {
367         out.println("invalid part");
368         return;
369         }
370         ContentType ct = new ContentType(sct);
371
372         res.setContentType(ct.getBaseType());
373         InputStream is = part.getInputStream();
374         int i;
375         while ((i = is.read()) != -1)
376         out.write(i);
377         out.flush();
378         out.close();
379     } catch (MessagingException mex) {
380         out.println(mex.toString());
381     }
382     }
383
384     /**
385      * This is a utility message that pretty-prints the message
386      * headers for message that is being displayed.
387      */

388     private void displayMessageHeaders(MailUserData mud, Message msg,
389                        ServletOutputStream out)
390     throws IOException {
391
392     try {
393         out.println("<b>Date:</b> " + msg.getSentDate() + "<br>");
394
395             Address[] fr = msg.getFrom();
396             if (fr != null) {
397                 boolean tf = true;
398                 out.print("<b>From:</b> ");
399                 for (int i = 0; i < fr.length; i++) {
400                     out.print(((tf) ? " " : ", ") + getDisplayAddress(fr[i]));
401                     tf = false;
402                 }
403                 out.println("<br>");
404             }
405
406             Address[] to = msg.getRecipients(Message.RecipientType.TO);
407             if (to != null) {
408                 boolean tf = true;
409                 out.print("<b>To:</b> ");
410                 for (int i = 0; i < to.length; i++) {
411                     out.print(((tf) ? " " : ", ") + getDisplayAddress(to[i]));
412                     tf = false;
413                 }
414                 out.println("<br>");
415             }
416
417             Address[] cc = msg.getRecipients(Message.RecipientType.CC);
418             if (cc != null) {
419                 boolean cf = true;
420                 out.print("<b>CC:</b> ");
421                 for (int i = 0; i < cc.length; i++) {
422                     out.print(((cf) ? " " : ", ") + getDisplayAddress(cc[i]));
423             cf = false;
424         }
425                 out.println("<br>");
426             }
427             
428         out.print("<b>Subject:</b> " +
429               ((msg.getSubject() !=null) ? msg.getSubject() : "") +
430               "<br>");
431
432         } catch (MessagingException mex) {
433         out.println(msg.toString());
434     }
435     }
436
437     /**
438      * This method displays the URL's for the available commands and the
439      * INBOX headerlist
440      */

441     private void displayHeaders(MailUserData mud,
442                 HttpServletRequest req,
443                                 ServletOutputStream out)
444     throws IOException {
445
446         SimpleDateFormat df = new SimpleDateFormat("EE M/d/yy");
447
448         out.println("<html>");
449         out.println("<HEAD><TITLE>JavaMail Servlet</TITLE></HEAD>");
450     out.println("<BODY bgcolor=\"#ccccff\"><hr>");
451     out.print("<center><font face=\"Arial,Helvetica\" font size=\"+3\">");
452     out.println("<b>Folder " + mud.getStore().getURLName() +
453             "/INBOX</b></font></center><p>");
454
455     // URL's for the commands that are available
456
out.println("<font face=\"Arial,Helvetica\" font size=\"+3\"><b>");
457         out.println("<a HREF=\"" +
458             HttpUtils.getRequestURL(req) +
459             "?logout=true\">Logout</a>");
460         out.println("<a HREF=\"" +
461             HttpUtils.getRequestURL(req) +
462             "?compose=true\" target=\"compose\">Compose</a>");
463     out.println("</b></font>");
464     out.println("<hr>");
465
466     // List headers in a table
467
out.print("<table cellpadding=1 cellspacing=1 "); // table
468
out.println("width=\"100%\" border=1>"); // settings
469

470     // sender column header
471
out.println("<tr><td width=\"25%\" bgcolor=\"ffffcc\">");
472     out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
473     out.println("<b>Sender</b></font></td>");
474     // date column header
475
out.println("<td width=\"15%\" bgcolor=\"ffffcc\">");
476     out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
477     out.println("<b>Date</b></font></td>");
478     // subject column header
479
out.println("<td bgcolor=\"ffffcc\">");
480     out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
481     out.println("<b>Subject</b></font></td></tr>");
482
483     try {
484         Folder f = mud.getFolder();
485         int msgCount = f.getMessageCount();
486         Message m = null;
487         // for each message, show its headers
488
for (int i = 1; i <= msgCount; i++) {
489                 m = f.getMessage(i);
490         
491         // if message has the DELETED flag set, don't display it
492
if (m.isSet(Flags.Flag.DELETED))
493             continue;
494
495         // from
496
out.println("<tr valigh=middle>");
497                 out.print("<td width=\"25%\" bgcolor=\"ffffff\">");
498         out.println("<font face=\"Arial,Helvetica\">" +
499                 ((m.getFrom() != null) ?
500                            m.getFrom()[0].toString() :
501                            "" ) +
502                 "</font></td>");
503
504         // date
505
out.print("<td nowrap width=\"15%\" bgcolor=\"ffffff\">");
506         out.println("<font face=\"Arial,Helvetica\">" +
507                             df.format((m.getSentDate()!=null) ?
508                       m.getSentDate() : m.getReceivedDate()) +
509                 "</font></td>");
510
511         // subject & link
512
out.print("<td bgcolor=\"ffffff\">");
513         out.println("<font face=\"Arial,Helvetica\">" +
514                     "<a HREF=\"" +
515                 HttpUtils.getRequestURL(req) +
516                             "?message=" +
517                             i + "\">" +
518                             ((m.getSubject() != null) ?
519                        m.getSubject() :
520                        "<i>No Subject</i>") +
521                             "</a>" +
522                             "</font></td>");
523                 out.println("</tr>");
524         }
525     } catch (MessagingException mex) {
526         out.println("<tr><td>" + mex.toString() + "</td></tr>");
527         mex.printStackTrace();
528     }
529
530     out.println("</table>");
531     out.println("</BODY></html>");
532     out.flush();
533     out.close();
534     }
535
536     /**
537      * This method handles the request when the user hits the
538      * <i>Compose</i> link. It send the compose form to the browser.
539      */

540     private void compose(MailUserData mud, HttpServletResponse res,
541              ServletOutputStream out)
542     throws IOException {
543     
544     res.setContentType("text/html");
545     out.println(composeForm);
546     out.close();
547     }
548
549     /**
550      * This method processes the send request from the compose form
551      */

552     private void send(HttpServletRequest req, HttpServletResponse res,
553               ServletOutputStream out, HttpSession ssn)
554     throws IOException {
555         
556         String JavaDoc to = req.getParameter("to");
557     String JavaDoc cc = req.getParameter("cc");
558     String JavaDoc subj = req.getParameter("subject");
559     String JavaDoc text = req.getParameter("text");
560
561     try {
562         MailUserData mud = getMUD(ssn);
563         if (mud == null)
564         throw new Exception JavaDoc("trying to send, but not logged in");
565
566         Message msg = new MimeMessage(mud.getSession());
567         InternetAddress[] toAddrs = null, ccAddrs = null;
568
569         if (to != null) {
570         toAddrs = InternetAddress.parse(to, false);
571         msg.setRecipients(Message.RecipientType.TO, toAddrs);
572         } else
573         throw new MessagingException("No \"To\" address specified");
574
575         if (cc != null) {
576         ccAddrs = InternetAddress.parse(cc, false);
577         msg.setRecipients(Message.RecipientType.CC, ccAddrs);
578         }
579
580         if (subj != null)
581         msg.setSubject(subj);
582
583         URLName u = mud.getURLName();
584         msg.setFrom(new InternetAddress(u.getUsername() + "@" +
585                         u.getHost()));
586
587         if (text != null)
588         msg.setText(text);
589
590         Transport.send(msg);
591         
592         out.println("<h1>Message sent successfully</h1></body></html>");
593         out.close();
594         
595     } catch (Exception JavaDoc mex) {
596         out.println("<h1>Error sending message.</h1>");
597         out.println(mex.toString());
598         out.println("<br></body></html>");
599     }
600     }
601
602
603     // utility method; returns a string suitable for msg header display
604
private String JavaDoc getDisplayAddress(Address a) {
605         String JavaDoc pers = null;
606         String JavaDoc addr = null;
607         if (a instanceof InternetAddress &&
608             ((pers = ((InternetAddress)a).getPersonal()) != null)) {
609         
610         addr = pers + " "+"&lt;"+((InternetAddress)a).getAddress()+"&gt;";
611         } else
612             addr = a.toString();
613         
614         return addr;
615     }
616
617     // utility method; retrieve the MailUserData
618
// from the HttpSession and return it
619
private MailUserData getMUD(HttpSession ses) throws IOException {
620     MailUserData mud = null;
621
622     if (ses == null) {
623         return null;
624     } else {
625         if ((mud = (MailUserData)ses.getValue("javamailservlet")) == null){
626         return null;
627         }
628     }
629     return mud;
630     }
631
632
633     public String JavaDoc getServletInfo() {
634         return "A mail reader servlet";
635     }
636
637     /**
638      * This is the HTML code for the compose form. Another option would
639      * have been to use a separate html page.
640      */

641     private static String JavaDoc composeForm = "<HTML><HEAD><TITLE>JavaMail Compose</TITLE></HEAD><BODY BGCOLOR=\"#CCCCFF\"><FORM ACTION=\"/servlet/JavaMailServlet\" METHOD=\"POST\"><input type=\"hidden\" name=\"send\" value=\"send\"><P ALIGN=\"CENTER\"><B><FONT SIZE=\"4\" FACE=\"Verdana, Arial, Helvetica\">JavaMail Compose Message</FONT></B><P><TABLE BORDER=\"0\" WIDTH=\"100%\"><TR><TD WIDTH=\"16%\" HEIGHT=\"22\"> <P ALIGN=\"RIGHT\"><B><FONT FACE=\"Verdana, Arial, Helvetica\">To:</FONT></B></TD><TD WIDTH=\"84%\" HEIGHT=\"22\"><INPUT TYPE=\"TEXT\" NAME=\"to\" SIZE=\"30\"> <FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica\"> (separate addresses with commas)</FONT></TD></TR><TR><TD WIDTH=\"16%\"><P ALIGN=\"RIGHT\"><B><FONT FACE=\"Verdana, Arial, Helvetica\">CC:</FONT></B></TD><TD WIDTH=\"84%\"><INPUT TYPE=\"TEXT\" NAME=\"cc\" SIZE=\"30\"> <FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica\"> (separate addresses with commas)</FONT></TD></TR><TR><TD WIDTH=\"16%\"><P ALIGN=\"RIGHT\"><B><FONT FACE=\"Verdana, Arial, Helvetica\">Subject:</FONT></B></TD><TD WIDTH=\"84%\"><INPUT TYPE=\"TEXT\" NAME=\"subject\" SIZE=\"55\"></TD></TR><TR><TD WIDTH=\"16%\">&nbsp;</TD><TD WIDTH=\"84%\"><TEXTAREA NAME=\"text\" ROWS=\"15\" COLS=\"53\"></TEXTAREA></TD></TR><TR><TD WIDTH=\"16%\" HEIGHT=\"32\">&nbsp;</TD><TD WIDTH=\"84%\" HEIGHT=\"32\"><INPUT TYPE=\"SUBMIT\" NAME=\"Send\" VALUE=\"Send\"><INPUT TYPE=\"RESET\" NAME=\"Reset\" VALUE=\"Reset\"></TD></TR></TABLE></FORM></BODY></HTML>";
642
643 }
644
645
646 /**
647  * This class is used to store session data for each user's session. It
648  * is stored in the HttpSession.
649  */

650 class MailUserData {
651     URLName url;
652     Session session;
653     Store store;
654     Folder folder;
655
656     public MailUserData(URLName urlname) {
657     url = urlname;
658     }
659
660     public URLName getURLName() {
661     return url;
662     }
663
664     public Session getSession() {
665     return session;
666     }
667
668     public void setSession(Session s) {
669     session = s;
670     }
671
672     public Store getStore() {
673     return store;
674     }
675
676     public void setStore(Store s) {
677     store = s;
678     }
679
680     public Folder getFolder() {
681     return folder;
682     }
683
684     public void setFolder(Folder f) {
685     folder = f;
686     }
687 }
688
Popular Tags