This sample script demonstrates how to attach a template file to an email.

Applicability

This functionality is only available within the control script as it requires access to the formControl object.

Prerequisites

To utilize this feature, users must first upload the template file in the Designer. The file is attached to a specified behavior, allowing users to have a different template per form behavior for the same form.

Code Sample

// Prepare attachment
//
byte[] content =  bpmAppService.BPMSServices.DmsService.GetAppFileContent("ESR Template - 2021-04-21.docx", formObject); // the name of the file uploaded 
SortedList _attachList = new SortedList();    
_attachList.Add(domainObject.BPMAPP_Hatch_PMR_ProjectProjectRef.SAPNo + ".docx", content); // this is the name of file in email
//
// Send the email
//
var subject = "The subject";
var body = "The body";
var email = "recipient@site.com";
bpmAppService.BPMSServices.NotificationService.Send(subject, body, NotificationAgent.Email, true, email, _attachList);