Add

Overview 

Adds a new email to your account and returns an initialized object

Syntax 

Add(1)

Function Properties 

OrdinalTypeDescription
1objectRequiredJSON object containing new email properties

Example 

This sample code adds an email to your account:

1var newMail = {
2    "CustomerKey" : "test_email_key",
3    "Name" : "Test Email",
4    "CategoryID" : "123456",
5    "HTMLBody" : "<b>This is a test email</b>",
6    "TextBody" : "This is a test email",
7    "Subject" : "Test Email Subject",
8    "IsActive" : "true",
9    "IsHTMLPaste" : "true",
10    "Status" : "active",
11    "EmailType" : "HTML",
12    "CharacterSet" : "US-ASCII",
13    "HasDynamicSubjectLine" : "false"
14};
15var myEmail = Email.Add(newMail);

The CategoryID value in the above code sample assigns the new email message to a specific folder. To save the new email message to the default folder in your account, remove the CategoryID value entirely.