I have a requirement where the user will select multiple attachments of choice from a list of Documents and Email them.
- VS Code
- AL Language Extension
- Microsoft Dynamics Business Central
Create a drill-down on the field where the user will select attachments from a list of Documents. Here we have used Page Document Attachment Details as a drill-down page where I have attached some documents.
In the above code, I have created a drill-down of page Document Attachment Details.
SetSelectionFilter() – To get selected attachments from the list of Documents.
Here I have created Instream and Outstream Objects for Attachments as shown below:
In the below code Rec_Sample is a Record variable for sample table which contains the Media field “Document Reference” which stores the unique Document Reference ID of a single Document.
After that, the same document is exported and Imported using Exportstream and Importstream.
And AddAttachmentStream is called with the Instream object to add the attachment. This is done for the number of attachments selected and then the mail is sent.
This way we can send Multiple attachments selected by the user and email them.
Hope this helps!