Email attachements

hi im trying to add attachments to the standard send option in posted sales invoice im wondering how the pdf is generated for the invoice so i can attach multiple ones to this mail

Hi hamza_bouzidi
have a look at this link. I added the updated code for BC20 in the comments

https://robertostefanettinavblog.com/2020/06/15/business-central-send-email-with-multi-attachments/

1 Like

The PDF for the posted sales invoice is generated based on the report that is specified in the “Report ID” field on the Sales & Receivables Setup page. By default, the report used is “Sales Invoice”, but you can specify a different report if needed.

To add attachments to the standard send option, you can customize the codeunit that handles the sending of emails. In this case, you will need to modify the codeunit that is assigned to the “Email Body Codeunit ID” field on the Sales & Receivables Setup page.

You can add code to the codeunit that retrieves the PDF for the posted sales invoice and attaches it to the email message. To attach multiple PDFs, you will need to loop through the posted sales invoices and generate a PDF for each one.

It is recommended that you make a copy of the original codeunit and modify the copy, so that you do not affect the standard functionality. Additionally, it is important to thoroughly test any modifications to ensure that they do not cause any issues with the system.