Skip to content

New

Creates a new message instance for sending.

1
$Messages.New(to?: string, subject?: string, body?: string):Message

Parameters

string to optional
    The email address of the primary recipient. Optional, but at least one recipient must be specified before sending.

string subject optional
    The subject of the message. Optional.

string body optional
    The body of the message. Optional.

Returns

A new Message instance.

Remarks

This method only prepares the message; it does not send it. To send the message, use the Message.Send method.

Create and send a simple message

1
2
var msg = $Messages.New( '[email protected]' , 'remember' , 'Remember the milk!.' );
msg.Send();

Create a message with multiple recipients and attachments

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var msg = $Messages.New();
msg.Subject = $Xml.Evaluate('Dispatch/Subject');
msg.Body = $Xml.Evaluate('Dispatch/Body');
msg.DeleteAfter = $Calendar.AddDays($Calendar.Today,30);

$Xml.SelectAll("To/Address", function(adr) {

    var type = adr.Evaluate('Type/Code');

    if (type === 'To') {
        msg.To(adr.Evaluate('EMailAddress'));
    } else if (type === 'CC') {
        msg.CC(adr.Evaluate('EMailAddress'));
    } else if (type === 'BCC') {
        msg.BCC(adr.Evaluate('EMailAddress'));
    }

});

$Xml.SelectAll("Attachments/Attachment", function(att) {
    msg.AttachFile(att.Evaluate('File'));
});
msg.Send();

See Also