Scripting Objects Reference

Email Marketer utilizes two power objects for personalization; Message and User. With these objects, you can easily control the entire message if you want. Normally, the scripting objects are used for global personalization scripting.

The Message Object Model

The message object is available to you within the Personalization Script Code with the following properties and methods:
Property Type Description
FromName Text Read/write the display name of the sender, the default value is loaded from the sender account.

Example
Message.FromName = "Nesox Solutions"

FromEmail Text Read/write the email address of the sender, the default value is loaded from the sender account.

Example
Message.FromEmail = "someone@nesox.com"

ReplyName Text Read/write the display name of the reply-to, the default value is loaded from the reply-to account.

Example
Message.ReplyName = "Nesox Solutions"

ReplyEmail Text Read/write the email address of the reply-to, the default value is loaded from the reply-to account.

Example
Message.ReplyEmail = "someone@nesox.com"

Subject Text Read/write the message subject.

Example
Message.Subject = Message.Subject & " for " & User("FirstName")

CC Text Read/write the email for carbon copy recipients.

Example
If User("AlternativeEmail") <> "" Then Message.CC = User("AlternativeEmail")

BCC Text Read/write the email for blind carbon copy recipients.

Example
Message.BCC = "someone@nesox.com"
Message.BCC = "someone1@nesox.com; someone2@nesox.com"

Text Object Access the plain text message, Message.Text is a Body object. For more details, please reference Body.

Example
Message.Text.LoadFromFile "c:\newsletter1.txt"

Html Object Access the HTML message, Message.Html is a Body object. For more details, please reference Body.

Example
Message.Html.LoadFromFile "c:\newsletter1.htm"

Format Text Read/write the message format, "Text", "Html" or "Automatic".

Example
Message.Format = User("Format")

Body Object Equals Text or Html object for inline scripting.
Attachments Object Access the attachments in the message.

Example
Message.Attachments.Add "c:\news.pdf"

Cancelled Bool Know whether the delivery of this message is cancelled.

Example
If Message.Cancelled Then MsgBox Message.Email & " was cancelled."

DateTime Datetime Read the last operation time for the message.

Example (for success or failure messages block)
Set Sys = CreateObject("Scripting.FileSystemObject")
Set Txt = Sys.OpenTextFile("c:\mylog.txt", 8)
Txt.Write(Message.Email & ": " & Message.DateTime & vbCrlf)
Txt.Close

ErrorNumber Number Read the error number for a failure or cancelled message.

Example (for failure messages block)
Set Sys = CreateObject("Scripting.FileSystemObject")
Set Txt = Sys.OpenTextFile("c:\mylog.txt", 8)
Txt.Write(Message.Email & ": " & Message.ErrorNumber & " " & Message.ErrorText & vbCrlf)
Txt.Close

ErrorText Text Read the error description for a failure or cancelled message.

Example (for failure messages block)
Set Sys = CreateObject("Scripting.FileSystemObject")
Set Txt = Sys.OpenTextFile("c:\mylog.txt", 8)
Txt.Write(Message.Email & ": " & Message.ErrorNumber & " " & Message.ErrorText & vbCrlf)
Txt.Close

UserKey Text Read the key field value of the recipient. Used for calling back after delivery.

Example (for success messages block)
Message.ListConnection.Execute "UPDATE List SET DeliveryTime=Now() WHERE ID=" & Message.UserKey

Email Text Read the email address of the recipient. Used for calling back after delivery.

Example (for success messages block)
Message.ListConnection.Execute "UPDATE List SET DeliveryTime=Now() WHERE Email='" & Message.Email & "'"

ListConnection Object ADO database connection object for the mailing list. Used for calling back after delivery.

Example
Message.ListConnection.Execute "UPDATE List SET DeliveryTime=Now() WHERE Email='" & Message.Email & "'"

Method Returns Description
Reset Nothing Clear the message contents and attachments.
Cancel Nothing Cancel the message personalization and creation and this message will not be delivered.

The Body, Text, HTML Object Model

The body object equals to the current Text or Html object. It is only accessible for inline script. For global scripting, use Message.Text or Message.Html instead. The Body object is available to you within the Personalization Script Code with the following properties and methods:
Property Type Description
Text Text Access the plain-text character-string or HTML source codes.

Example
Message.HTML.Text = "<b>Hello!</b>"

Method Returns Description
Write Nothing Append text to plain-text content or HTML source codes.

Example
Body.Write "String"

Special Notice
For inline scripting, ="String" equals to Body.Write "String"

WriteLine Nothing Append text with line break to plain-text content or HTML source codes.

Example
Body.WriteLine "String"

InsertFromFile Nothing Insert the contents of a text/html file to the current position.

Example
Body.InsertFromFile "c:\copyright.htm"

LoadFromFile Nothing Overwrite the message text with the contents of a text/html file.

Example
Body.LoadFromFile "c:\newsletter1.htm"

Clear Nothing Empty the message text.

Example
Message.Text.Clear
Message.Html.Clear

End Nothing Stop generating this message text.

Example
Message.Text.End
Message.Text.WriteLine "String" 
' this will not work any more

SaveToFile Nothing Save the message text to a text/html file.

Example
Message.Html.SaveToFile "c:\" & User("Email") & ".htm"
Message.Text.SaveToFile "c:\" & User("Email") & ".txt"

The Attachments Object Model

The attachments object is available to you within the Personalization Script Code with the following properties and methods:
Property Type Description
Count Number Read the attachments amount.
Method Returns Description
Add Nothing Add a new attachment by its location.

Example
Message.Attachments.Add "FilePath"

Remove Nothing Remove an attached file by its file name or index.

Example
Message.Attachments.Remove "FilePath"

Clear Nothing Remove all attached files.

Example
If User("NoAttachment") = "1" Then
  Message.Attachments.Clear
End If

Find Number Find attachment by its file name and returns the index.

Example
If Message.Attachments.Find("FilePath") >= 0 Then
  Message.Attachments.Remove "FilePath"
End If

The User Object Model

The attachments object is available to you within the Personalization Script Code with the following properties and methods:
Property Type Description
Properties Text Read/Write the recipient's attributes from a specific column as a character-string. Returns the contents of the current value from this column as a variant-type.
(contains NULL values, numbers, dates, etc.)

Example
Message.Subject = User.Properties("FirstName") & ", " & Message.Subject

Special Notice
1. User("fieldname") equals to User.Properties("fieldname")
2. For inline scripting, [fieldname] also equals to User.Properties("fieldname")

Email Text Read/Write the recipient's email address.

Example
If User.Email = "" And User("AlternativeEmail") <> "" Then
  User.Email = User("AlternativeEmail")
End If

FullName Text Read/Write the recipient's full name.

Example
If User.FullName = "" Then
  User.FullName = User("FirstName")
End If

Key Text Read/Write the recipient's key field.

Example
If User.Key <> "" Then
  Message.HTML = Replace(Message.HTML, "#key#", User.Key)
End If

Connection Object ADO database connection object for the mailing list.

Example
Set rs = User.Connection.Execute("SELECT OrderNo FROM Orders WHERE UserID=" & User("ID"))
User("OrderNo") = rs("OrderNo")

Method Returns Description
Clear Nothing Remove all user attributes in the object.

Example
User.Clear