SendHTMLEmail
Generates and sends an e-mail using a site-based E-mail Template. The e-mail can be sent to one or many recipients, with or without attachments.
Syntax
SendHTMLEmail( TemplateName, Recipients, Attachments, BinaryAttachments );
Parameters
Parameter Name | Type | Description | Optional? | Default Value |
---|---|---|---|---|
TemplateName | String | The name of a valid e-mail template, as it appears in the Site Map Inspector interface. | No | n/a |
Recipients | String | A list containing one or more e-mail addresses. If multiple addresses are used, they must be separated using pipe symbols (|). If this argument is omitted, the resulting e-mail will be sent to the addresses specified in the template's properties; otherwise, the e-mail will be sent to the addresses listed in the function call. | Yes (see Description) | "" |
Attachments | String | A list containing one or more valid Document Item keywords. The function will attempt to locate the specified documents when the e-mail is sent, and attach PDFs based on them to the resulting e-mail. If a document item is associated with a particular sub-model, you can specify this by appending a pipe symbol to the item's name, followed by the sub-model's name. If no sub-model is specified, the function will look for the document in the main model. All attachments will be assigned a randomly-generated file name with the .pdf extension. To give an attachment a specific file name, append two pipe symbols to its template name, followed by the intended file name and extension. | Yes | "" |
BinaryAttachments | String | A comma-separated list containing the names of one or more Model Identifiers. For each identifier in this list, the function will generate a file using the identifier's value as the file's base64 binary, and attach it to the resulting e-mail. To assign a specific name to any of these files, append a pipe symbol to the identifier name, followed by the chosen file name, such as VARImageBinary|MyImage.png. Any item that is not given a file name will be assigned a random one with the .pdf extension. | Yes | "" |
Output
If successful, the function will return a confirmation message describing what was sent; otherwise, it will return a value of False.
Use Case
The following example will send an e-mail based on a template called WeeklyDigest:
SendHTMLEmail( "WeeklyDigest", "mary.jones@multiwareprod.com|bill.mckinnon@multiwareprod.com", "ProductSummary||Summary-19Mar2018.pdf,WeeklyHours|HRTemplates", "VARCompanyLogo|MultiWare-Logo.png" );
The expression's syntax mean the resulting e-mail will have the following properties:
- Recipients: Mary Jones and Bill McKinnon at MultiWare Productions.
- Attachments: One PDF based on the ProductSummary template and given the name Summary-19Mar2018.pdf, and another based on the WeeklyHours template and given a random file name. The second template exists on the HRTemplates sub-model.
- Binary Attachments: One image file created using the base64 binary value stored in VARCompanyLogo, given the file name MultiWare-Logo.png.