Difference between revisions of "SendEmailUsingTemplate"

From AgileApps Support Wiki
imported>Aeric
m (Text replace - 'sendEmailUsingTemplate(' to 'Functions.sendEmailUsingTemplate(')
 
imported>Aeric
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:sendEmailUsingTemplate}}
{{DISPLAYTITLE:sendEmailUsingTemplate}}
:<tt>Functions.sendEmailUsingTemplate(String objectId, String recordId, String to, String cc, String subject, String bodyTemplateId, String attachmentTemplateId, String attachmentIdList)</tt>
Sends an Email message using the Template identified by the <tt>bodyTemplateId</tt> parameter. Generates one or more documents and includes them as attachments.


:Sends an Email message evaluating the Template identified by <tt>bodyTemplateId</tt> as the body of the email message.
'''Prerequisites'''
:Go to '''[[File:GearIcon.png]] > Objects > {Object} > Email Templates'''
:Define or find a template.
:Get the ID of that template, for use in the <tt>bodyTemplateID</tt> parameter.


Sends an email with content based on a template defined in the 'Template' object.  
'''Syntax'''<br>
Basic:
:<syntaxhighlight lang="java" enclose="div">
Result result = Functions.sendEmailUsingTemplate(String objectID, String recordID,
    String to, String cc, String subject, String bodyTemplateID,
    String attachmentTemplateIdList, String attachmentIDList);
</syntaxhighlight>


In order to send an email using a template, add a template in the 'Template' object.
with Bcc:
:<syntaxhighlight lang="java" enclose="div">
Result result = Functions.sendEmailUsingTemplate(String objectID, String recordID,
    String to, String cc, String Bcc, String subject, String bodyTemplateID,
    String attachmentTemplateIdList, String attachmentIDList);
</syntaxhighlight>


The template created is associated with a template ID.
with Bcc and from whom:
 
Populate the bodyTemplateID of the API with the template ID.
 
'''Syntax'''
:<syntaxhighlight lang="java" enclose="div">
:<syntaxhighlight lang="java" enclose="div">
Result result = Functions.sendEmailUsingTemplate(String objectID, String recordID,  
Result result = Functions.sendEmailUsingTemplate(String objectID, String recordID,  
     String to, String cc, String subject, String bodyTemplateID,  
     String to, String cc, String Bcc, String subject, String bodyTemplateID,  
     String attachmentTemplateIdList, String attachmentID);
     String attachmentTemplateIdList, String attachmentIDList,
    String fromName, String fromAddress);
</syntaxhighlight>
</syntaxhighlight>


Line 24: Line 35:
:;to:A list of comma-separated email addresses
:;to:A list of comma-separated email addresses
:;cc:A list of comma separated email addresses
:;cc:A list of comma separated email addresses
:;subject:A descriptive text string
:;bcc:Optional. List of comma separated email addresses for "blind copies" (Recipients do not see addresses in this list.)
:;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.
:;subject:A descriptive text string. If this value is an empty string, the subject specified in the template is used. Otherwise, the specified string is used.
:;attachmentTemplateIdList:A list of comma-separated [[Print Templates|print template]] identifiers. The template variables are evaluated at run time, their values are substituted, and the resulting documents are then sent as attachments.
:;bodyTemplateID:ID of the [[Email Template]]. It is evaluated at run time, template variables substituted, and then sent as the body of the message.
:;attachmentIdList:A list of comma-separated document identifiers in your documents folder to send as attachments
:;attachmentTemplateIdList:A list of comma-separated [[Document Template]] identifiers. The template variables are evaluated at run time, their values are substituted, and the resulting documents are then sent as attachments (in addition to any attachments defined by the Email Template).
:::'''Note:'''<br>Do not choose a template based on a JSP page for use as an attachment.<br>''Learn more:'' [[JSP Attachment Deprecation]]
:;attachmentIdList:A list of comma-separated document identifiers to send as attachments
 
;;fromName: The name the email is coming from.
;;fromAddress: The address the email is coming from.


'''Return'''
'''Return'''
 
:[[Result Class|<tt>Result</tt> object]]
[[Result Class|<tt>Result</tt> object]]


;Example:This example calls <tt>sendEmailUsingTemplate</tt> for a contact.
;Example:This example calls <tt>sendEmailUsingTemplate</tt> for a contact.
Line 52: Line 67:
|}
|}
<noinclude>
<noinclude>
[[Category:Email and Document Management]]
 
[[Category:Java API]]
</noinclude>
</noinclude>

Latest revision as of 00:01, 15 October 2014

Sends an Email message using the Template identified by the bodyTemplateId parameter. Generates one or more documents and includes them as attachments.

Prerequisites

Go to GearIcon.png > Objects > {Object} > Email Templates
Define or find a template.
Get the ID of that template, for use in the bodyTemplateID parameter.

Syntax
Basic:

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

with Bcc:

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

with Bcc and from whom:

Result result = Functions.sendEmailUsingTemplate(String objectID, String recordID, 
    String to, String cc, String Bcc, String subject, String bodyTemplateID, 
    String attachmentTemplateIdList, String attachmentIDList,
    String fromName, String fromAddress);

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
bcc
Optional. List of comma separated email addresses for "blind copies" (Recipients do not see addresses in this list.)
subject
A descriptive text string. If this value is an empty string, the subject specified in the template is used. Otherwise, the specified string is used.
bodyTemplateID
ID of the Email Template. It is evaluated at run time, template variables substituted, and then sent as the body of the message.
attachmentTemplateIdList
A list of comma-separated Document Template identifiers. The template variables are evaluated at run time, their values are substituted, and the resulting documents are then sent as attachments (in addition to any attachments defined by the Email Template).
Note:
Do not choose a template based on a JSP page for use as an attachment.
Learn more: JSP Attachment Deprecation
attachmentIdList
A list of comma-separated document identifiers to send as attachments
fromName
The name the email is coming from.
fromAddress
The address the email is coming from.

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);