sendEmailUsingTemplate

From AgileApps Support Wiki
Revision as of 22:51, 20 December 2010 by imported>Aeric (Text replace - 'sendEmailUsingTemplate(' to 'Functions.sendEmailUsingTemplate(')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Functions.sendEmailUsingTemplate(String objectId, String recordId, String to, String cc, String subject, String bodyTemplateId, String attachmentTemplateId, String attachmentIdList)
Sends an Email message evaluating the Template identified by bodyTemplateId as the body of the email message.

Sends an email with content based on a template defined in the 'Template' object.

In order to send an email using a template, add a template in the 'Template' object.

The template created is associated with a template ID.

Populate the bodyTemplateID of the API with the template ID.

Syntax

Result result = Functions.sendEmailUsingTemplate(String objectID, String recordID, 
    String to, String cc, String subject, String bodyTemplateID, 
    String attachmentTemplateIdList, String attachmentID);

Parameters

objectID
The identifier of the related object
recordID
The identifier of the related record
to
A list of comma-separated email addresses
cc
A list of comma separated email addresses
subject
A descriptive text string
bodyTemplateID
ID of the template created in 'Template' object. Its template is evaluated at run time, the template variables substituted, and then sent as the body of the message.
attachmentTemplateIdList
A list of comma-separated print template identifiers. The template variables are evaluated at run time, their values are substituted, and the resulting documents are then sent as attachments.
attachmentIdList
A list of comma-separated document identifiers in your documents folder to send as attachments

Return

Result object

Example
This example calls sendEmailUsingTemplate for a contact.
String contactID = "";
String attachmentTemplateIdList = "";
String bodyTemplateID = "";
String attachmentID = "";

// Some code to populate contactID.
// Populate attachmentTemplateIdList manually from the template Ids displayed in UI from Template object 
// Populate bodyTemplateID  manually from the template Id displayed in the UI from Template object

Functions.sendEmailUsingTemplate("CONTACT", contactID, "joe.smith@acme.com,mark.smith@acme.com", 
"cc.smith@xyz.com", "Some subject", bodyTemplateID, attachmentTemplateIdList, attachmentID);