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

Sending Email from Cloud Code

Sending Email from Cloud Code

The cloud code functionality also allows you to send emails in very convenient way. All emails are based on Email Templates that you can define using the Emails screen in the Telerik Platform portal. You can also use a mustache syntax to replace variables passed by the call in your template, so that you can include contextual information in the actual email.

Using Email Templates

You can use your existing email templates and send emails messages based on them. Sending an email is done with the following method:

Everlive.Email.sendEmailFromTemplate(templateName, recipients, context, callback);

The meaning of the parameters is explained below:

  • templateName - the Name of the email template to use. For sending custom email template use it's id.
  • recipients - an array of recipients. An array with the email addresses of the recipients.
  • context - a context object specifying each variable that is used in the email template.
  • callback - function that is invoked on after the request completes. The arguments are respectively error and result. If the request is successful, error will be null.

This is a sample, showing sending of an email whenever you read data:

Everlive.Events.beforeRead(function(request, context, done) {
    var templateName = "WelcomeEmail";
    var recipients = ['newuser@telerik.com'];
    var emailContext = {
        CustomSubject: "Email sent from cloud code.",
        IntValue: 222
    };

    Everlive.Email.sendEmailFromTemplate(templateName, recipients, emailContext, function(err, result) {
        //some other logic here...
        done();
    });
});

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.