KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > util > ListMailer


1 package com.dotmarketing.util;
2
3 import java.util.Iterator JavaDoc;
4 import java.util.Set JavaDoc;
5
6
7 /**
8  * @author rocco
9  *
10  * To change this generated comment edit the template variable "typecomment":
11  * Window>Preferences>Java>Templates.
12  * To enable and disable the creation of type comments go to
13  * Window>Preferences>Java>Code Generation.
14  */

15 public class ListMailer {
16     
17     private String JavaDoc fromEmail;
18     private Set JavaDoc toList;
19     private String JavaDoc ccEmail;
20     private String JavaDoc bccEmail;
21     private String JavaDoc subject;
22     private String JavaDoc htmlMessage;
23     
24     
25     public int SendMesageToList(){
26         int numberSent = 0;
27         
28         if(fromEmail != null && toList!=null && htmlMessage!= null && subject != null){
29             Iterator JavaDoc mli = toList.iterator();
30             while(mli.hasNext()){
31                 
32                 Mailer mailer = new Mailer();
33                 mailer.setFromEmail(this.fromEmail);
34                 mailer.setToEmail((String JavaDoc) mli.next());
35                 if(this.bccEmail!=null){
36                     mailer.setBcc(this.bccEmail);
37                 }
38                 if(this.ccEmail!=null){
39                     mailer.setBcc(this.ccEmail);
40                 }
41                 mailer.setSubject(subject);
42                 mailer.setHTMLAndTextBody(htmlMessage);
43                 mailer.sendMessage();
44             }
45         }
46             
47         
48         return numberSent;
49     }
50
51     /**
52      * Returns the bccEmail.
53      * @return String
54      */

55     public String JavaDoc getBccEmail() {
56         return bccEmail;
57     }
58
59     /**
60      * Returns the ccEmail.
61      * @return String
62      */

63     public String JavaDoc getCcEmail() {
64         return ccEmail;
65     }
66
67     /**
68      * Returns the fromEmail.
69      * @return String
70      */

71     public String JavaDoc getFromEmail() {
72         return fromEmail;
73     }
74
75     /**
76      * Returns the toList.
77      * @return java.util.List
78      */

79     public java.util.Set JavaDoc getToList() {
80         return toList;
81     }
82
83     /**
84      * Sets the bccEmail.
85      * @param bccEmail The bccEmail to set
86      */

87     public void setBccEmail(String JavaDoc bccEmail) {
88         this.bccEmail = bccEmail;
89     }
90
91     /**
92      * Sets the ccEmail.
93      * @param ccEmail The ccEmail to set
94      */

95     public void setCcEmail(String JavaDoc ccEmail) {
96         this.ccEmail = ccEmail;
97     }
98
99     /**
100      * Sets the fromEmail.
101      * @param fromEmail The fromEmail to set
102      */

103     public void setFromEmail(String JavaDoc fromEmail) {
104         this.fromEmail = fromEmail;
105     }
106
107     /**
108      * Sets the toList.
109      * @param toList The toList to set
110      */

111     public void setToList(java.util.Set JavaDoc toList) {
112         this.toList = toList;
113     }
114
115     /**
116      * Returns the htmlMessage.
117      * @return String
118      */

119     public String JavaDoc getHtmlMessage() {
120         return htmlMessage;
121     }
122
123     /**
124      * Returns the subject.
125      * @return String
126      */

127     public String JavaDoc getSubject() {
128         return subject;
129     }
130
131     /**
132      * Sets the htmlMessage.
133      * @param htmlMessage The htmlMessage to set
134      */

135     public void setHtmlMessage(String JavaDoc htmlMessage) {
136         this.htmlMessage = htmlMessage;
137     }
138
139     /**
140      * Sets the subject.
141      * @param subject The subject to set
142      */

143     public void setSubject(String JavaDoc subject) {
144         this.subject = subject;
145     }
146
147 }
148
Popular Tags