java.lang.Objectorg.mozilla.javascript.ScriptableObject
org.wso2.mashup.hostobjects.email.Email
public class Email
<EmailConfig>
<host>smtp.gmail.com</host>
<port>25</port>
<username>username@gmail.com</username>
<password>password</password>
</EmailConfig>
eg:
function sendEmail(){
var email = new Email("host", "port", "username", "password");
var file = new File("temp.txt");
email.from = "keith@wso2.com";
email.to = "keith@wso2.com"; // alternatively message.to can be a array of strings. Same goes for cc and bcc
email.cc = "keith@wso2.com";
email.bcc = "keith@wso2.com";
email.subject = "WSO2 Mashup server 1.0 Released";
email.addAttachement(file, "temp.txt"); // Optionally can add attachements, it has a variable number of arguments. each argument can be a File hostObject or a string representing a file.
email.text = "WSO2 Mashup server 1.0 was Released on 28th January 2008";
email.send();
}
| Field Summary |
|---|
| Fields inherited from class org.mozilla.javascript.ScriptableObject |
|---|
CONST, DONTENUM, EMPTY, PERMANENT, READONLY,
UNINITIALIZED_CONST |
| Fields inherited from interface org.mozilla.javascript.Scriptable |
|---|
NOT_FOUND |
| Constructor Summary | |
|---|---|
Email() |
|
| Method Summary | |
|---|---|
java.lang.String |
getClassName()Return the name of the class. |
static org.mozilla.javascript.Scriptable |
jsConstructor(org.mozilla.javascript.Context cx,
java.lang.Object[] args,
org.mozilla.javascript.Function ctorObj,
boolean inNewExpr)The Email Object has three different constructors. |
static void |
jsFunction_addAttachement(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj) |
static void |
jsFunction_addAttachment(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)Add attachments to the mail been sent. |
void |
jsFunction_send()Send the mail out email.send() |
java.lang.String[] |
jsGet_bcc() |
java.lang.String[] |
jsGet_cc() |
java.lang.String |
jsGet_from() |
java.lang.String |
jsGet_html() |
java.lang.String |
jsGet_subject() |
java.lang.String |
jsGet_text() |
java.lang.String[] |
jsGet_to() |
void |
jsSet_bcc(java.lang.Object bccObject)The bcc address that the mail is sent to email.bcc = "keith@wso2.com"; OR var bcc = new Array(); bcc[0] = "jonathan@wso2.com"; bcc[1] = "keith@wso2.com"; email.bcc = bcc; |
void |
jsSet_cc(java.lang.Object ccObject)The cc address that the mail is sent to email.cc = "keith@wso2.com"; OR var cc = new Array(); cc[0] = "jonathan@wso2.com"; cc[1] = "keith@wso2.com"; email.cc = cc; |
void |
jsSet_from(java.lang.String from)The from address to appear in the email email.from = "keith@wso2.com"; |
void |
jsSet_html(java.lang.Object html)The body of the email to be sent. |
void |
jsSet_subject(java.lang.String subject)The subject of the mail been sent email.subject = "WSO2 Mashup server 1.0 Released"; |
void |
jsSet_text(java.lang.String text)The body text of the mail been sent email.text = "WSO2 Mashup server 1.0 was Released on 28th January 2008"; |
void |
jsSet_to(java.lang.Object toObject)The to address that the mail is sent to email.to = "keith@wso2.com"; OR var to = new Array(); to[0] = "jonathan@wso2.com"; to[1] = "keith@wso2.com"; email.to = to; |
| Methods inherited from class org.mozilla.javascript.ScriptableObject |
|---|
associateValue, callMethod, callMethod, defineClass,
defineClass, defineClass, defineConst, defineConstProperty,
defineFunctionProperties, defineProperty, defineProperty,
defineProperty, defineProperty, delete, delete, deleteProperty,
deleteProperty, get, get, getAllIds, getAssociatedValue,
getAttributes, getAttributes, getAttributes, getAttributes,
getClassPrototype, getDefaultValue, getDefaultValue,
getFunctionPrototype, getGetterOrSetter, getIds,
getObjectPrototype, getParentScope, getProperty, getProperty,
getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue,
has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed,
put, put, putConst, putConstProperty, putProperty, putProperty,
redefineProperty, sealObject, setAttributes, setAttributes,
setAttributes, setAttributes, setGetterOrSetter, setParentScope,
setPrototype |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString,
wait, wait, wait |
| Constructor Detail |
|---|
public Email()
| Method Detail |
|---|
public java.lang.String getClassName()
getClassName in interface
org.mozilla.javascript.ScriptablegetClassName in class
org.mozilla.javascript.ScriptableObject
public static org.mozilla.javascript.Scriptable jsConstructor(org.mozilla.javascript.Context cx,
java.lang.Object[] args,
org.mozilla.javascript.Function ctorObj,
boolean inNewExpr)
throws org.wso2.mashup.MashupFault
The Email Object has three different constructors. Choose one depending on your configuration and your needs. 1. The first constructor takes no parameters and uses configuration information specified in the server.xml. Using a configuration such as this is useful if you want to use a default email account to send out mail from your mashups. It also reduces the hassle of having to key in the configuration details each time you need a new email object. var email = new Email(); 2. The second constructor, unlike the first, requires the user to provide the configuration details each time he creates a new email object. The benefit is that no server configuration is needed and you can use diffent accounts when ever you need. The configuration details should be given as follows: var email = new Email("smtp.gmail.com", "25", "username@gmail.com", "password"); // host, port, username, password 3. The third is a slight variant of the second. It does not require a port to be specified: var email = new Email("smtp.gmail.com", "username@gmail.com", "password"); // host, username, password
org.wso2.mashup.MashupFault
public void jsSet_from(java.lang.String from)
throws org.wso2.mashup.MashupFault
The from address to appear in the email
email.from = "keith@wso2.com";
org.wso2.mashup.MashupFault
public java.lang.String jsGet_from()
throws javax.mail.MessagingException
javax.mail.MessagingException
public java.lang.String[] jsGet_to()
throws org.wso2.mashup.MashupFault
org.wso2.mashup.MashupFault
public void jsSet_to(java.lang.Object toObject)
throws org.wso2.mashup.MashupFault
The to address that the mail is sent to
email.to = "keith@wso2.com"; OR var to = new Array(); to[0] = "jonathan@wso2.com"; to[1] = "keith@wso2.com"; email.to = to;
org.wso2.mashup.MashupFault
public java.lang.String[] jsGet_cc()
throws org.wso2.mashup.MashupFault
org.wso2.mashup.MashupFault
public void jsSet_cc(java.lang.Object ccObject)
throws org.wso2.mashup.MashupFault
The cc address that the mail is sent to
email.cc = "keith@wso2.com"; OR var cc = new Array(); cc[0] = "jonathan@wso2.com"; cc[1] = "keith@wso2.com"; email.cc = cc;
org.wso2.mashup.MashupFault
public java.lang.String[] jsGet_bcc()
throws org.wso2.mashup.MashupFault
org.wso2.mashup.MashupFault
public void jsSet_bcc(java.lang.Object bccObject)
throws org.wso2.mashup.MashupFault
The bcc address that the mail is sent to
email.bcc = "keith@wso2.com"; OR var bcc = new Array(); bcc[0] = "jonathan@wso2.com"; bcc[1] = "keith@wso2.com"; email.bcc = bcc;
org.wso2.mashup.MashupFault
public void jsSet_subject(java.lang.String subject)
throws org.wso2.mashup.MashupFault
The subject of the mail been sent
email.subject = "WSO2 Mashup server 1.0 Released";
org.wso2.mashup.MashupFault
public java.lang.String jsGet_subject()
throws org.wso2.mashup.MashupFault
org.wso2.mashup.MashupFault
public void jsSet_text(java.lang.String text)
throws org.wso2.mashup.MashupFault
The body text of the mail been sent
email.text = "WSO2 Mashup server 1.0 was Released on 28th January 2008";
org.wso2.mashup.MashupFaultpublic java.lang.String jsGet_text()
public void jsSet_html(java.lang.Object html)
throws org.wso2.mashup.MashupFault
The body of the email to be sent. This function can be used to send HTML mail.
email.html = "
"; // Setthing the HTML content as a String
OR
email.html =
; // Setting the HTML content as an XML object
org.wso2.mashup.MashupFaultpublic java.lang.String jsGet_html()
public void jsFunction_send()
throws org.wso2.mashup.MashupFault
Send the mail out
email.send()
org.wso2.mashup.MashupFault
public static void jsFunction_addAttachement(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.wso2.mashup.MashupFault
org.wso2.mashup.MashupFault
public static void jsFunction_addAttachment(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.wso2.mashup.MashupFault
Add attachments to the mail been sent. This function has a variable number of arguments, each argument can be a File hostObject or a string representing a file.
var file = new File("temp.txt"); // A file exists at temp.txt
email.addAttachement(file, "temp.txt");
org.wso2.mashup.MashupFault