Creating the content of the message body
To define the contents of the message body, you must use its BodyText property. It is of type string. Its value can be formatted either as a plain text or as HTML text.
The following code creates a message body with HTML text through the Native API.
NewslettersManager manager = NewslettersManager.GetManager();
MessageBody messageBody = manager.CreateMessageBody(Guid.NewGuid());
messageBody.MessageBodyType = MessageBodyType.HtmlText;
messageBody.BodyText = "<h1>Sample title</h1><p>Sample text.</p>";
messageBody.Name = "SampleMessageTemplate";
messageBody.IsTemplate = true;
manager.SaveChanges();
First, you initialize the NewslettersManager. Then, you call CreateMessageBody to create a message body. Then, you set theMessageBodyType property. It can have one of the following values:
- HtmlText
- PlainText
- InternalPage
Then, you set the BodyText property. Finally, you save the changes.
Adding parameters to the content
You are allowed to add several parameters to the content of the message body, e.g. name of the subscriber, title of the mailing list, etc. Here is a list of the parameters you can add to the text and their string representations:
The following code creates an HTML text as string and makes use of some of the parameters.
string bodyText = "<h1>Hello, {|Subscriber.FirstName|}!</h1><p>This is a message from {|MailingList.DefaultFromName|}
reagarding {|MailingList.DefaultSubject|}.</p>";
| Parameter name | Parameter string |
| Subscriber's first name | {|Subscriber.FirstName|} |
| Subscriber's last name | {|Subscriber.LastName|} |
| Subscriber's email | {|Subscriber.Email|} |
| Mailing list's title | {|MailingList.Title|} |
| Default from name | {|MailingList.DefaultFromName|} |
| Default reply-to email | {|MailingList.DefaultReplyToEmail|} |
| Default subject | {|MailingList.DefaultSubject|} |
| Subscription reminder | {|MailingList.SubscriptionReminder|} |