Business Central Send Email with Multi Attachments

Business Central Send Email with Multi Attachments

The purpose of this APP is to be able to send an email with a series of attachments; in this case the email is sent to the user (to himself) so that it can then be changed in the email client before sending. In practice, both the Master document (ex Purchase Order) and all attachments are sent in bulk (obviously, keep an eye on the size of the files!).

It is therefore useful to be able to send blocks of attachments to a document.

Sendmail Multi Attachments Process

  • Master Document (es Purchase Order) + ALL Linked Documents (attachments) will be sent


Code sample


Before using the function, however, you need to add your email address in the user setup.


Use the “Attachments function” to insert attachments (example on Purchase Order page)

Select necessary files to use as attachments which will then have to be sent

By pressing the “Send attached documents” button, an email is automatically sent with attachments, the printout of the order in pdf and all the files associated with the order at the user email set.

As already mentioned, the purpose is to prepare an email complete with all attachments in addition to the master document to be sent in bulk to the user. Then you can send it to whoever you need after changing it from the mail client.


…with ALL attachments!


4 thoughts on “Business Central Send Email with Multi Attachments

  • 19 August 2020 at 6:45 PM

    Hi i see a reference for 50102, what is that reference to ?

  • 15 October 2020 at 4:16 PM


    Do you happen to know how to overwrite SMTP settings to use a different server/user to:
    1. Allows BC users to send emails as themselves, and
    2. To allow jobs to send emails as Customer Service, or Billing accounts
    To allow this to happen, we need two different SMTP configurations.

    Thank you,

  • 12 December 2020 at 9:59 AM

    Wіth havin ѕo muⅽh сontent ɗo you ever run into any issues of plagorism oг
    copyright violation? Ⅿy site һas a loot οf unique content I’ѵe eіther cгeated myself or outsokurced but it
    ѕeems a lot of it is popping it uр aⅼl oveг the internet withput mʏ agreement.
    Ɗо yoս kniw ɑny methods to helρ ѕtop content from Ƅeing stolen?
    І’d truly apрreciate it.

  • 5 April 2022 at 3:42 PM

    Updated Code:

    PROCEDURE ReportSendMailWithExternalAttachment(
    ReportToSend: Integer;
    Recordr: RecordRef;
    TableID: Integer;
    DocNo: Text;
    ToAddr: List of [Text];
    Subject: Text[100];
    Body: Text[200];
    AttachmentName: Text[100];
    Param: Text; var Purchaseheader: Record “Purchase Header”): Boolean
    TempBlob: Codeunit “Temp Blob”;
    outStreamReport: OutStream;
    inStreamReport: InStream;
    TempBlobAtc: Array[10] of Codeunit “Temp Blob”;
    outStreamReportAtc: Array[10] of OutStream;
    inStreamReportAtc: Array[10] of InStream;
    Parameters: Text;
    EmailObj: Codeunit Email;
    EmailMsg: Codeunit “Email Message”;
    Question: Label ‘Are you Sure you want to send an email to %1’;
    SendYesNo: Boolean;
    // Attachments
    FullFileName: Text;
    DocumentAttachment: record “Document Attachment”;
    i: Integer;

    EmailMsg.Create(ToAddr, Subject, Body, false);
    //Generate blob from report
    Report.SaveAs(ReportToSend, Param, ReportFormat::Pdf, outStreamReport, Recordr);
    // Mail.AddAttachmentStream(inStreamReport, AttachmentName);
    i := 1;

    //Get attachment from the document – streams
    DocumentAttachment.setrange(“Table ID”, TableID);
    DocumentAttachment.setrange(“No.”, DocNo);
    if DocumentAttachment.FindSet() then begin
    if DocumentAttachment.”Document Reference ID”.HasValue then begin
    FullFileName := DocumentAttachment.”File Name” + ‘.’ + DocumentAttachment.”File Extension”;
    if DocumentAttachment.”Document Reference ID”.ExportStream(outStreamReportAtc[i]) then begin
    //Mail Attachments
    EmailMsg.AddAttachment(FullFileName, ‘PDF,’, inStreamReportAtc[i]);
    i += 1;
    until DocumentAttachment.NEXT = 0;

    //Send mail

Comments are closed.