new Mail(MailObject)
Parameters:
Name |
Type |
Argument |
Description |
MailObject |
object
|
<optional>
|
JS object containing different part of the email
in JSON format. Supported properties are {'sender', 'to', 'cc', 'bcc', 'subject', 'subjectEncoding', 'parts'}. |
Examples
//create empty $.net.Mail
var mail = new $.net.Mail();
//create email from JS Object and send
var mail = new $.net.Mail({
sender: {address: "sender@sap.com"},
to: [{ name: "John Doe", address: "john.doe@sap.com", nameEncoding: "US-ASCII"}, {name: "Jane Doe", address: "jane.doe@sap.com"}],
cc: ["cc1@sap.com", {address: "cc2@sap.com"}],
bcc: [{ name: "Jonnie Doe", address: "jonnie.doe@sap.com"}],
subject: "subject",
subjectEncoding: "UTF-8",
parts: [ new $.net.Mail.Part({
type: $.net.Mail.Part.TYPE_TEXT,
text: "The body of the mail.",
contentType: "text/plain",
encoding: "UTF-8",
})]
});
var returnValue = mail.send();
var response = "MessageId = " + returnValue.messageId + ", final reply = " + returnValue.finalReply;
$.response.status = $.net.http.OK;
$.response.contentType = "text/html";
$.response.setBody(response);
-
bcc :array
-
Property used for initializing "bcc" property of the mail. It is an
array containing objects with three properties. The first one is the
name of the person, the second one is the actual mail address, the
third one is the name encoding ex. {name: "John Doe", address:
"john.doe@sap.com", nameEncoding: "UTF-8"} or {name: "John Doe",
address: "john.doe@sap.com"} or {address: "john.doe@sap.com"} or just
"john.doe@sap.com". The name and the name encoding of the person can
be skipped, but the mail address cannot. If 'address' property is not
set, the mail won't be send at all.
Type:
-
cc :array
-
Property used for initializing "cc" property of the mail. It is an
array containing objects with three properties. The first one is the
name of the person, the second one is the actual mail address, the
third one is the name encoding ex. {name: "John Doe", address:
"john.doe@sap.com", nameEncoding: "UTF-8"} or {name: "John Doe",
address: "john.doe@sap.com"} or {address: "john.doe@sap.com"} or just
"john.doe@sap.com". The name and the name encoding of the person can
be skipped, but the mail address cannot. If 'address' property is not
set, the mail won't be send at all.
Type:
-
parts :array
-
Property used for initializing "parts" property of the mail. It is an
array containing $.net.Mail.Part() objects.
Type:
-
sender :object
-
Property used for initializing "sender" property of the mail. The
object contains three properties. The first one is the name of the
person, the second one is the actual mail address, the third one is
the name encoding ex. {name: "John Doe", address: "john.doe@sap.com",
nameEncoding: "UTF-8"} or {name: "John Doe", address:
"john.doe@sap.com"} or {address: "john.doe@sap.com"} or just
"john.doe@sap.com". The name and the name encoding of the person can
be skipped, but the mail address cannot. If 'address' property is not
set, the mail won't be send at all. The "sender" property is a
mandatory field, if it is not set or is not set properly the mail
won't be sent.
Type:
-
subject :string
-
Property used for initializing "subject" property of the mail
Type:
-
subjectEncoding :string
-
Property used for initializing "subjectEncoding" property of the
mail. It is the encoding of the subject. If this property is not set,
the default value is "UTF-8".
Type:
-
to :array
-
Property used for initializing "to" property of the mail. It is an
array containing objects with three properties. The first one is the
name of the person, the second one is the actual mail address, the
third one is the name encoding ex. {name: "John Doe", address:
"john.doe@sap.com", nameEncoding: "UTF-8"} or {name: "John Doe",
address: "john.doe@sap.com"} or {address: "john.doe@sap.com"} or just
"john.doe@sap.com". The name and the name encoding of the person can
be skipped, but the mail address cannot. If 'address' property is not
set, the mail won't be send at all.
Type: