View Javadoc
1   /*
2    * Copyright 2008 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package tools.gsf.facade.runtag.mail;
18  
19  import COM.FutureTense.Interfaces.ICS;
20  import COM.FutureTense.Util.ftErrors;
21  import tools.gsf.facade.runtag.AbstractTagRunner;
22  
23  /**
24   * {@code<mail.send to="recipient,recipient"
25   * <p>
26   * [from="your e-mail"] [subject="subject of message"] [body="message body"]
27   * [replyto="your alternate e-mail address"] [contenttype="content format"]
28   * [charset="character set"] />}
29   *
30   * @author Tony Field
31   * @since 4-Nov-2008
32   */
33  public final class Send extends AbstractTagRunner {
34      public Send() {
35          super("mail.send");
36      }
37  
38      public void setTo(String commaSeparatedListOfEmailAddresses) {
39          set("to", commaSeparatedListOfEmailAddresses);
40      }
41  
42      public void setFrom(String from) {
43          set("from", from);
44      }
45  
46      public void setSubject(String subject) {
47          set("subject", subject);
48      }
49  
50      public void setBody(String body) {
51          set("body", body);
52      }
53  
54      public void setReplyto(String replyto) {
55          set("replyto", replyto);
56      }
57  
58      public void setContentType(String contentType) {
59          set("contenttype", contentType);
60      }
61  
62      public void setCharset(String charset) {
63          set("charset", charset);
64      }
65  
66      public static boolean sendMail(ICS ics, String to, String from, String subject, String body, String replyto,
67                                     String contentType, String charset) {
68          Send send = new Send();
69          send.setTo(to);
70          send.setFrom(from);
71          send.setSubject(subject);
72          send.setBody(body);
73          send.setReplyto(replyto);
74          send.setContentType(contentType);
75          send.setCharset(charset);
76          send.execute(ics);
77          return ics.GetErrno() != ftErrors.emailexception;
78      }
79  
80      public static boolean sendMail(ICS ics, String to, String subject, String body) {
81          return sendMail(ics, to, null, subject, body, null, null, null);
82      }
83  
84  }