I’ve finally gotten my report to run both client-side and via mail merge process.
Now I need to automate multiple reports and multiple recipients. This snippet of code, which Vin gave me some time ago may be pertinent:
const mailMergeContext = {SMTPToEmail: five.field.EmailAddress,
SMTPToName: "Staff",
SMTPAttachments: [reportResult.report, reportResult2.report]};
This appears to let me attach multiple reports to a single email. I presume I would first generate each report on the server, and keep track of the various reportResult objects.
My particular application knows, via various tables, which people get which reports. I was hoping to be able to attach multiple email addresses to a single email with the pertinent report attached. The other thread you pointed me to only showed how to attach a To, CC and BCC email address to an email, but not how to attach multiple emails to the TO address. However, the snippet below from your examples page calls the context item SMTPAddresses and looks like the value is an array because of the [ and ]. If that is true, I could still send a report to multiple people on one email, right?
const mailMergeContext = {};
mailMergeContext['SMTPAddresses'] = [five.emailAddress('john@example.co', 'John Citizen')];
mailMergeContext['SMTPCcAddresses'] = [five.emailAddress('kirk@example.co', 'Finance'), five.emailAddress('belinda@example.co', 'Orders')];
mailMergeContext['SMTPBccAddresses'] = [five.emailAddress('management@example.co', 'Management')];
const mailResult = five.executeAction('SubmissionReceived', mailMergeContext);
In my current Access application, we do this. Create an email, attach the document, then add all the required email addresses, then send the email. Unless you tell me there is no way to do this (multiple TO addresses on a single email), I will need to switch perspective and send a single email to each person with all of the documents they would receive.
So please verify that the first code snippet above works for adding multiple documents to a single email, and also advise if I am correct that I can add multiple TO addresses to a single email (not cc and bcc, but multiple TO addresses). This will tell me how to build my logic for generating the reports. Thanks…
