Difference between revisions of "SendEmail"

From LongJump Support Wiki
imported>Aeric
imported>Aeric
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
;Syntax:
;Syntax:
:<syntaxhighlight lang="java" enclose="div">
:<syntaxhighlight lang="java" enclose="div">
Functions.sendEmail(String objectId, String recordId, String to, String cc,  
Functions.sendEmail(String objectName, String recordId, String to, String cc,  
           String subject, String body, String attachmentTemplateIdList,  
           String subject, String body, String attachmentTemplateIdList,  
           String attachmentIdList {, TenantContext context} );
           String attachmentIdList {, TenantContext context} );
Line 10: Line 10:


;Parameters:
;Parameters:
:;objectId:The identifier of the related object
:;objectName:The name of the object the email relates to, or the objectId. This field is required, and must be a non-empty string.
:;recordId:The identifier of the related record
:;recordId:The identifier of the record the message relates to. This field can be an empty string (<tt>""</tt>).
:;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

Latest revision as of 00:12, 18 February 2012

Sends an email.

Syntax
Functions.sendEmail(String objectName, String recordId, String to, String cc, 
          String subject, String body, String attachmentTemplateIdList, 
          String attachmentIdList {, TenantContext context} );
Parameters
objectName
The name of the object the email relates to, or the objectId. This field is required, and must be a non-empty string.
recordId
The identifier of the record the message relates to. This field can be an empty string ("").
to
A list of comma-separated email addresses
cc
A list of comma separated email addresses
subject
A descriptive text string
body
The contents of the email message (static text).
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
context
An optional TenantContext Object used to send an email using a user-alias in another tenancy.
Considerations
  • You can use this method to send attachments with data from the record using the template defined in the print template.
  • In order for the template variables to be populated, the print template ID passed to the API must be defined in the object that is specified in the first parameter - objectID
  • Successful execution of the call adds an entry in the 'Activity History' section of the record that is specified in the second parameter - recordID.
  • The values specified in the 'to' and 'cc' fields can be retrieved using requestParams object.
  • Direct email addresses can also be passed as a string in the API parameters.
  • In order to send email to multiple addresses with multiple attachments specify the various values in a comma-separated string.
Return
Result object
Example
This example calls sendMail for a contact.
String contactID = ""; 
String attachmentIdList = "";
String attachmentTemplateIdList = "";

// Some code to populate contactID. 
// Some code to populate attachmentIdList.
// Populate the attachmentTemplateIdList with template ID of the Print Template

Result sendEmailResult = Functions.sendEmail("CONTACT", contactID, "joe.smith@acme.com,mark.smith@acme.com", 
    "cc.smith@xyz.com", "Some subject", 
    "Hello, This email was sent from the Java API",
    attachmentTemplateIdList, attachmentIdList);