Skip to content

$.net.Mail

$.net.Mail class for constructing and sending multi-part emails.

Overview

Sample Usage

Note

Requires a running mail server. If mailConfig is not set the api defaults to a local mail server. For more information please take a look here.

let net = $.net;

// Create email from JS Object.
let mail = new $.net.Mail({
    sender: {address: "sender@sap.com"},
    to: [{ name: "John Doe", address: "john.doe@sap.com"}, {name: "Jane Doe", address: "jane.doe@sap.com"}],
    cc: [{address: "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",
    })]
});


let returnValue = mail.send();
$.response.setBody(JSON.stringify(returnValue));

Constructors

new $.net.Mail(MailObject)

Parameters

Parameter Name Description Required Type
MailObject JS object containing different part of the email in JSON format. Supported properties are {'sender', 'to', 'cc', 'bcc', 'subject', 'subjectEncoding', 'parts'}. optional object

Classes

Classes Description
Part Class for constructing email parts.

Properties

Name Description Type
bcc Property used for initializing "bcc" property of the mail. It is an array containing objects with three properties - name, encoding and address with address being required. array
cc Property used for initializing "cc" property of the mail. It is an array containing objects with three properties - name, encoding and address with address being required. array
parts Property used for initializing "parts" property of the mail. It is an array containing $.net.Mail.Part() objects. array
sender Property used for initializing "sender" property of the mail. It is an array containing objects with three properties - name, encoding and address with address being required. This property is required or the mail won't be sent. object
subject Property used for initializing "subject" property of the mail. string
subjectEncoding 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". string
to Property used for initializing "to" property of the mail. It is an array containing objects with three properties - name, encoding and address with address being required. array

Functions

Function Description Returns
send() method that returns an object containing two properties: 'messageId' and 'finalReply'. object

Addition mail client options can be found here: - SMTP/SMTPS - IMAP - POP3