Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

Creating Email Templates Programmatically

Creating Email Templates Programmatically

In addition to the portal, you can make a POST request to the EmailTemplates RESTful API to create email templates. It is part of the metadata API.

In a JSON-formatted payload to the request provide the email template information (none of the fields is mandatory), as follows:

Field Name Description
Name An arbitrary name that you will use to identify the email template. It is used when sending emails from this template. Must be unique for the application.
FromName Full name of the sender that recipients see.
FromEmail An email address that recipients see as sender. Must be a valid email address.
ReplyToEmail Specify this if you want your users to reply to a different email address than the sender's email address. Must be a valid email address.
Cc Add a list of CC (carbon copy) recipient addresses. Each of these addresses is visible to the rest of the CC recipients.
Bcc Add a list of BCC (blind carbon copy) recipient addresses. Messages sent to BCC recipients appear as if sent only to a single recipient.
Subject The email subject that recipients see.
MessageText The email body in plain-text form. Optional.
MessageHtml The email body in HTML form. You can use HTML and CSS for styling.
SendMode Specifies in what formats to send the message body. 1=HTML, 2=text, 3=both.

Example:

var object = {
    "Subject" : "Test email subject",
    "MessageHtml" : "Sample email message.",
    "FromName": "John Smith",
    "FromEmail": "john.smith@example.com",
    "Cc" : "recipient1@example.com",
    "Bcc" : "recipient2@example.com",
    "SendMode": 1
};

$.ajax({
    type: "POST",
    url: 'https://api.everlive.com/v1/Metadata/Applications/your-app-id/EmailTemplates',
    contentType: "application/json",
    headers: { "Authorization" : "Masterkey your-master-key" },
    data: JSON.stringify(object),
    success: function(data){
        alert("Email templates was successfully created.");
    },
    error: function(error){
        alert(JSON.stringify(error));
    }
})
Request:
    POST https://api.everlive.com/v1/Metadata/Applications/your-app-id/EmailTemplates
Headers:
    Authorization: Masterkey 
    Content-Type: application/json
Payload - raw:
    {
      "Subject" : "Test email subject",
       "MessageHtml" : "Sample email message.",
      "FromName": "John Smith",
      "FromEmail": "john.smith@example.com",
      "Cc" : "recipient1@telerik.com",
      "Bcc" : "recipient2@telerik.com",
      "SendMode": 1
    }
Response:
    Status: 200 OK

After you have created your email template, you can use it to send emails as explained in these articles:

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.