Core library object for managing Email Studio email messages — create, retrieve, update, remove, validate, and check content.
The Email Core library object provides programmatic management of email message assets in Email Studio. Use it to create, retrieve, update, remove, validate, and check content of email messages.
Requires Platform.Load("core", "1.1.5") before use.
Methods
| Method | Returns | Description |
|---|---|---|
Email.Init(key) |
EmailInstance | Initialize an Email object by external key |
Email.Add(properties) |
EmailInstance | Create a new email message |
Email.Retrieve(filter) |
object[] | Retrieve email messages matching a filter |
<EmailInstance>.Update(properties) |
string | Update the initialized email message |
<EmailInstance>.Remove() |
string | Delete the initialized email message |
<EmailInstance>.Validate() |
object | Run validation checks on the email message |
<EmailInstance>.CheckContent() |
object | Run content checks on the email message |
Email.Init
Initializes an Email instance bound to the specified external key. Required before invoking any instance method on the returned object. External keys cannot be set in the UI — set one via SOAP API, or look up the value via Email.Retrieve().
Syntax
Email.Init(key)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
key |
string | Yes | External key of the email message |
Return value
EmailInstance
Examples
Platform.Load("core", "1.1.5");
var myEmail = Email.Init("myEmail");
Email.Add
Creates a new email message from the supplied properties and returns an initialized email instance. Unlike most static Add methods, this returns an EmailInstance, not "OK".
Syntax
Email.Add(properties)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
properties |
object | Yes | CustomerKey, Name, optional CategoryID, HTMLBody, TextBody, Subject, EmailType, … |
Return value
EmailInstance
Examples
Platform.Load("core", "1.1.5");
var newMail = {
CustomerKey: "test_email_key",
Name: "Test Email",
HTMLBody: "<b>This is a test email</b>",
TextBody: "This is a test email",
Subject: "Test Email Subject",
EmailType: "HTML",
CharacterSet: "US-ASCII"
};
var myEmail = Email.Add(newMail);
Email.Retrieve
Returns an array of email messages matching the specified filter.
Syntax
Email.Retrieve(filter)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
filter |
object | Yes | PascalCase WSProxy-style filter object: {Property, SimpleOperator, Value} |
Return value
object[]
Examples
Platform.Load("core", "1.1.5");
var results = Email.Retrieve({ Property: "CustomerKey", SimpleOperator: "equals", Value: "myEmail" });
<EmailInstance>.Update
Updates the email message with the supplied attributes.
Syntax
<EmailInstance>.Update(properties)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
properties |
object | Yes | Attributes to change on the email message |
Return value
"OK" on success.
Examples
Platform.Load("core", "1.1.5");
var myEmail = Email.Init("myEmail");
var status = myEmail.Update({ Name: "Updated Name", Subject: "Updated Email Subject" });
<EmailInstance>.Remove
Removes the previously initialized email message.
Syntax
<EmailInstance>.Remove()
Return value
"OK" on success.
Examples
Platform.Load("core", "1.1.5");
var myEmail = Email.Init("myEmail");
myEmail.Remove();
<EmailInstance>.Validate
Runs validation checks on the previously initialized email message. Returns a {Task: {ValidationStatus: boolean, ValidationMessages: string}} object.
Syntax
<EmailInstance>.Validate()
Return value
object — with Task.ValidationStatus (boolean) and Task.ValidationMessages (string).
Examples
Platform.Load("core", "1.1.5");
var myEmail = Email.Init("myEmail");
var results = myEmail.Validate();
Write(results.Task.ValidationStatus);
Write(results.Task.ValidationMessages);
<EmailInstance>.CheckContent
Runs content checks on the previously initialized email message. Returns a {Task: {CheckPassed: boolean, ResultMessage: string}} object.
Syntax
<EmailInstance>.CheckContent()
Return value
object — with Task.CheckPassed (boolean) and Task.ResultMessage (string).
Examples
Platform.Load("core", "1.1.5");
var myEmail = Email.Init("myEmail");
var results = myEmail.CheckContent();
Write(results.Task.CheckPassed);
Write(results.Task.ResultMessage);