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

Sending Email Programmatically

Sending Email Programmatically

After you have created an email template the RESTful API provides an endpoint for sending email messages based on a specified email template.

You need to provide the following details when using it:

  • In the URL, the email template's ID or name
  • In the body, a Recipients list containing recipient email addresses
  • In the body, a Context object that sets values to all placeholders used in the template

The next example adds two Recipients and sets values for the CustomSubject, PromoCode, and SpecialOffer placeholders that were defined in the template as follows:

  • {{CustomSubject}}
  • {{PromoCode}}
  • {{SpecialOffer}}
var attributes = {
    "Recipients": [
        "user1@example.com",
        "user2@example.com"
    ],
    "Context": {
        "CustomSubject": "New offer",
        "PromoCode": "New promo code value",
        "SpecialOffer": "Free popcorn for a year"
    }
};

$.ajax({
    type: "POST",
    url: 'https://api.everlive.com/v1/Metadata/Applications/your-app-id/EmailTemplates/email-template-id-here/send',
    contentType: "application/json",
    headers: {
        "Authorization": "Masterkey your-master-key"
    },
    data: JSON.stringify(attributes),
    success: function(data) {
        alert("Email successfully sent.");
    },
    error: function(error) {
        alert(JSON.stringify(error));
    }
})

See Also

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