web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Using "Email Item" Table directly to send custom mail

(0) ShareShare
ReportReport
Posted on by 449

Hello Team,

I am Using "Email Item" Table directly to send custom mail. I now need help to add attachment. I need to add a custom report in attachment.

Below is the code.

action(Send)
            {
                ApplicationArea = all;
                Promoted = true;
                trigger OnAction()
                var
                    EndLine: Char;
                    EndLine2: Char;

                begin
                    EndLine := 13;
                    EndLine2 := 10;
                    WITH TempEmailItem DO BEGIN
                      
                        "Send to" := 'xyz@gmailcom';
                        Subject := 'Purchase Order# ' ;
                        "Message Type" := "Message Type"::"Custom Message";
                        
                        CLEAR(Body);

                        Body.CREATEOUTSTREAM(BodyStream);

                       
                        BodyStream.WriteText('Dear Sir/Madam,' + FORMAT(EndLine+ FORMAT(EndLine2));
                        BodyStream.WriteText('');
                        BodyStream.WriteText('Please find attached Purchase Order# ');

                    
                        
                       // "Attachment File Path" := FileManagement.Magicpath();
                        //"Attachment Name" := 'PO Report.pdf';
                        Commit();
                       
                        CalcFields(Body);

                 
                        Commit();
                        Send(FALSE);
                        

                    end;
                end;

            }
I have the same question (0)
  • Suggested answer
    Sumit_Nandha Profile Picture
    160 on at

    Hello,

    Using Email Item Table is quite easy for sending mails. It has a very easy structure and nice error handling. However, has also some limitations. The biggest one is not possible to add an attachment when developing for the cloud, at least I was not able to do so. This is because in the table there is no function to add attachments other than specifying attachment path – and that is not possible for the cloud.

    To create an mail you can add a variable for the table – use it as a temporary. Then you need to fill the fields such as Send to, Send CC, Send BCC, Subject, and Body.

    The Body field is type Blob. Which allows, without any additional work, to add the body from the report. Simple save report to HTML using method SaveAs. The OutStream will contain an email body. In the end, you just need to run function Send which is in the table.

    Read this blog for more details

    http://www.mynavblog.com/2019/12/17/sending-mails-in-the-cloud/

  • Manish Ratan Profile Picture
    449 on at

    Thanks for Reply,

    Is there any other way to use it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,986 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,071 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 975 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans