1. Home
  2. /
  3. Developer Guide
  4. /
  5. JavaScript Library
  6. /
  7. Send Email

Send Email

This function allows you to programmatically send an email.

Syntax: SendEmail(<Email Object>)

This function takes as argument an object that has the following fields:

  • emailFrom: set “Org” / “CurrentUser”
  • emailTo: recipient email (you can put several emails separated by “;”).
  • emailCC: carbon copies recipient (you can put several emails separated by “;”).
  • emailBCC: blind carbon copies recipient (you can put several emails separated by “;”).
  • emailReplyTo: email address to reply to for the mail message (you can put several emails separated by “;”).
  • emailSubject: message subject.
  • emailBody: message body.
  • emailIsBodyHtml: set true/false to indicate whether the mail message body is in HTML or not.
  • enableSsl: set true/false to either use SSL or not when connecting to the SMTP server. By default the value is false.

Usage:

var strBody = “Email message body”;
var Email = { emailFrom: “Org”, emailTo: “address1@example.com”, emailCC: “address2@example.com;address3@example.com”, emailBCC: ” “, emailReplyTo: ” “, emailSubject: “Email Subject”, emailBody: strBody, emailIsBodyHtml: true, enableSsl:true };
var ObjResult = SendEmail(Email);
var status  = ObjResult.msgSuccess;
var message = ObjResult.msgInfo;

Output:

Success: A success flag is returned with value = true.The following message will be displayed “Email sent.”
Failure: A success flag is returned with value = false. An error message will be displayed.

Note:

The SendEmail() method uses the SMTP configuration defined on the Organization page in the setup area. If no SMTP server and credentials are defined, the SendEmail() method will default to using the SMTP credentials defined at the current user’s level.

Was this article helpful to you? No Yes

How can we help?