1 package com.protomatter.syslog; 2 3 52 53 import java.io.*; 54 import java.util.*; 55 import com.protomatter.util.*; 56 57 60 class MailMessage 61 implements java.io.Serializable 62 { 63 private String subject = null; 64 private Vector to = null; 65 private Vector cc = null; 66 private Vector bcc = null; 67 private String fromAddress = null; 68 private String fromName = null; 69 70 private String bodyString = null; 71 private MIMEMessage bodyMime = null; 72 73 76 public MailMessage() 77 { 78 super(); 79 } 80 81 84 public void setTo(Vector to) 85 { 86 this.to = to; 87 } 88 91 public Vector getTo() 92 { 93 return (this.to == null) ? new Vector() : this.to; 94 } 95 96 97 101 public void setCC(Vector cc) 102 { 103 this.cc = cc; 104 } 105 109 public Vector getCC() 110 { 111 return (this.cc == null) ? new Vector() : this.cc; 112 } 113 114 115 119 public void setBCC(Vector bcc) 120 { 121 this.bcc = bcc; 122 } 123 127 public Vector getBCC() 128 { 129 return (this.bcc == null) ? new Vector() : this.bcc; 130 } 131 132 133 136 public void setFromAddress(String from) 137 { 138 this.fromAddress = from; 139 } 140 143 public String getFromAddress() 144 { 145 return this.fromAddress; 146 } 147 148 149 152 public void setFromName(String from) 153 { 154 this.fromName = from; 155 } 156 159 public String getFromName() 160 { 161 return this.fromName; 162 } 163 164 165 168 public void setSubject(String subject) 169 { 170 this.subject = subject; 171 } 172 175 public String getSubject() 176 { 177 return this.subject; 178 } 179 180 183 public void setBody(String body) 184 { 185 this.bodyString = body; 186 this.bodyMime = null; 187 } 188 191 public void setBody(MIMEMessage body) 192 { 193 this.bodyMime = body; 194 this.bodyString = null; 195 } 196 199 public Object getBody() 200 { 201 return (this.bodyString != null) 202 ? (Object )this.bodyString : (Object )this.bodyMime; 203 } 204 205 public String toString() 206 { 207 StringBuffer b = new StringBuffer (); 208 209 b.append("To: "); 210 Enumeration e = getTo().elements(); 211 while (e.hasMoreElements()) 212 { 213 b.append((String )e.nextElement()); 214 if (e.hasMoreElements()) 215 b.append(", "); 216 } 217 b.append("\n\r"); 218 219 220 b.append("From: "); 221 b.append(getFromName()); 222 b.append(" <"); 223 b.append(getFromAddress()); 224 b.append(">\n\r"); 225 226 227 e = getCC().elements(); 228 if (e.hasMoreElements()) 229 { 230 b.append("CC: "); 231 while (e.hasMoreElements()) 232 { 233 b.append((String )e.nextElement()); 234 if (e.hasMoreElements()) 235 b.append(", "); 236 } 237 b.append("\n\r"); 238 } 239 240 241 e = getBCC().elements(); 242 if (e.hasMoreElements()) 243 { 244 b.append("BCC: "); 245 while (e.hasMoreElements()) 246 { 247 b.append((String )e.nextElement()); 248 if (e.hasMoreElements()) 249 b.append(", "); 250 } 251 b.append("\n\r"); 252 } 253 254 255 b.append("Subject: "); 256 b.append(getSubject()); 257 b.append("\n\r"); 258 259 b.append("\n\r"); 260 b.append(getBody()); 261 262 return b.toString(); 263 } 264 } 265 | Popular Tags |