1 package org.apache.turbine.util.mail; 2 3 18 19 import javax.mail.MessagingException ; 20 21 import org.apache.torque.util.Criteria; 22 23 34 public class SimpleEmail 35 extends Email 36 { 37 38 private String contentType = null; 39 40 45 public SimpleEmail() throws MessagingException 46 { 47 super.init(); 48 } 49 50 69 public SimpleEmail(Criteria criteria) 70 throws MessagingException 71 { 72 super.init(); 73 this.initCriteria(criteria); 74 } 75 76 84 protected void initCriteria(Criteria criteria) 85 throws MessagingException 86 { 87 super.initCriteria(criteria); 88 89 if (criteria.containsKey(CONTENT_TYPE)) 90 { 91 contentType = criteria.getString(CONTENT_TYPE); 92 } 93 94 if (criteria.containsKey(EMAIL_BODY)) 95 { 96 setMsg(criteria.getString(EMAIL_BODY)); 97 } 98 else 99 { 100 setMsg("NO MESSAGE"); 101 } 102 } 103 104 111 public Email setMsg(String msg) throws MessagingException 112 { 113 if (contentType == null) 114 { 115 contentType = TEXT_PLAIN; 116 } 117 message.setContent(msg, contentType); 118 return this; 119 } 120 } 121 | Popular Tags |