Category:Email and Document Management
From LongJump Support Wiki
The Email and Document Management Java APIs manage Email and Documents.
sendEmail
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);
sendEmailUsingTemplate
- 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
- 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);
generateDocument
Functions.generateDocument(String objectId, String recordId, String templateId, String format)
- Generates document of templateId evaluated with params in the format.
- If the format is PDF, it generates the document in PDF format, otherwise HTML format. It relates this generated document to the object of type objectId and record identifier recordId.
Generates a document based on an HTML Print Template.
- Considerations
- JSP Print Templates cannot be used, currently.
Syntax
Result result; result = Functions.generateDocument(String objectID, String recordID, String printTemplateID, String format);
Parameters
- objectID
- The identifier of the related object
- recordID
- The identifier of the related record
- printTemplateID
- The name of the print template
- format
- You can specify CONSTANTS.DOCUMENT.HTML or CONSTANTS.DOCUMENT.PDF
- This option applies to HTML and PDF templates. Word templates always produce Word files. PowerPoint templates produce PowerPoint files.
Return
- Example
- This example calls generateDocument for a lead, creating a HTML document.
String printTemplateID = ""; String leadID = ""; // Some code to populate printTemplateID. // Some code to populate leadID. Result result = Functions.generateDocument("LEAD", leadID, printTemplateID, CONSTANTS.DOCUMENT.HTML); int resultCode = result.getCode(); if(resultCode < 0) { String msg = "Some Message"; Functions.debug(msg + ":\n" + result.getMessage()); // Log details Functions.throwError(msg + "."); // Error dialog } else { // Some business logic. }
Pages in category "Email and Document Management"
The following 3 pages are in this category, out of 3 total.