Difference between revisions of "SendEmail"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
 
(12 intermediate revisions by the same user not shown)
Line 3: Line 3:


;Syntax:
;Syntax:
Basic:
:<syntaxhighlight lang="java" enclose="div">
:<syntaxhighlight lang="java" enclose="div">
Functions.sendEmail(String objectName, String recordId, String to, String cc,  
Functions.sendEmail(String objectName, String recordId,  
           String subject, String body, String attachmentTemplateIdList,  
          String to, String cc, String subject, String body,  
           String attachmentIdList {, TenantContext context} );
           String attachmentTemplateIdList, String attachmentIdList);
</syntaxhighlight>
 
with Bcc:
:<syntaxhighlight lang="java" enclose="div">
Functions.sendEmail(String objectName, String recordId,
          String to, String cc, String bcc, String subject, String body,  
          String attachmentTemplateIdList, String attachmentIdList);
</syntaxhighlight>
 
with TenantContext:
:<syntaxhighlight lang="java" enclose="div">
Functions.sendEmail(String objectName, String recordId,
          String to, String cc, String subject, String body,  
           String attachmentTemplateIdList, String attachmentIdList,  
          TenantContext context);
</syntaxhighlight>
 
with fromName and fromAddress:
:<syntaxhighlight lang="java" enclose="div">
Functions.sendEmail(String objectName, String recordid, String to, String cc, String bcc,
          String subject, String body, String attachmentTemplateId,
          String attachmentIdList, String fromName, String fromAddress);  
</syntaxhighlight>
</syntaxhighlight>


Line 13: Line 36:
:;recordId:The identifier of the record the message relates to. This field can be an empty string (<tt>""</tt>).
:;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 to copy the message to. (Recipients see addresses in this list.)
:;bcc:Optional. List of comma separated email addresses for "blind copies" (Recipients do not see addresses in this list.)
:;subject:A descriptive text string
:;subject:A descriptive text string
:;body:The contents of the email message (static text).  
:;body:The contents of the email message (static text).  
:;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.
:;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.
:::'''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
:;attachmentIdList:A list of comma-separated document identifiers to send as attachments
::This parameter is '''''Reserved for future use.''''' Pass an empty string, for now.
:;context:An optional [[TenantContext Object]] used to send an email using a user-alias in another tenancy.
:;context:An optional [[TenantContext Object]] used to send an email using a user-alias in another tenancy.
:;fromName and fromAddress:Provide fromName and fromAddress as parameter to send email if emails are bouncing as spam. See http://agileappscloud.info/wiki/Email_Bounce_Notification for more information.


;Considerations:
;Considerations:
:* You can use this method to send attachments with data from the record using one or more [[Document Templates]].
:* You can use this method to send attachments with data from the record using one or more [[Document Templates]].


:* 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
:* In order for the template variables to be populated, the document 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.
:* Successful execution of the call adds an entry in the 'Activity History' section of the record that is specified in the second parameter - recordID.
Line 38: Line 63:


;Example:This example calls <tt>sendMail</tt> for a contact.
;Example:This example calls <tt>sendMail</tt> for a contact.
:{| border="0" cellpadding="5" cellspacing="0"
:{| border="0" cellpadding="5" cellspacing="0"
|
|

Latest revision as of 09:36, 26 September 2016

Sends an email.

Syntax

Basic:

<syntaxhighlight lang="java" enclose="div">

Functions.sendEmail(String objectName, String recordId,

         String to, String cc, String subject, String body, 
         String attachmentTemplateIdList, String attachmentIdList);

</syntaxhighlight>

with Bcc:

<syntaxhighlight lang="java" enclose="div">

Functions.sendEmail(String objectName, String recordId,

         String to, String cc, String bcc, String subject, String body, 
         String attachmentTemplateIdList, String attachmentIdList);

</syntaxhighlight>

with TenantContext:

<syntaxhighlight lang="java" enclose="div">

Functions.sendEmail(String objectName, String recordId,

         String to, String cc, String subject, String body, 
         String attachmentTemplateIdList, String attachmentIdList, 
         TenantContext context);

</syntaxhighlight>

with fromName and fromAddress:

<syntaxhighlight lang="java" enclose="div">

Functions.sendEmail(String objectName, String recordid, String to, String cc, String bcc,

         String subject, String body, String attachmentTemplateId, 
         String attachmentIdList, String fromName, String fromAddress); 

</syntaxhighlight>

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 to copy the message to. (Recipients see addresses in this list.)
bcc
Optional. List of comma separated email addresses for "blind copies" (Recipients do not see addresses in this list.)
subject
A descriptive text string
body
The contents of the email message (static text).
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.
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
context
An optional TenantContext Object used to send an email using a user-alias in another tenancy.
fromName and fromAddress
Provide fromName and fromAddress as parameter to send email if emails are bouncing as spam. See http://agileappscloud.info/wiki/Email_Bounce_Notification for more information.
Considerations
  • You can use this method to send attachments with data from the record using one or more Document Templates.
  • In order for the template variables to be populated, the document 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.

<syntaxhighlight lang="java" enclose="div"> String contactID = ""; String attachmentIdList = ""; String attachmentTemplateIdList = "";

// Some code to populate contactID. // Some code to populate attachmentIdList. // Populate the attachmentTemplateIdList with template ID of the Document 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);

</syntaxhighlight>