Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Email body From Report Selection

(0) ShareShare
ReportReport
Posted on by

Hi,

I have created a custom function to send emails with multiple attachments. Now I want to add email body from Report Selection page. I have a word layout under Email Body Layout Description field. I don't know how to get this custom layout to use in SMTP(Codeunit 400).CREATEMESSAGE.

Please guide me to any out of box piece of code dealing with this functionality or any hints.

Thanks,

Umair

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Email body From Report Selection

    Never mind, I figured the issue. I was passing wrong value to last parameter of CREATEMESSAGE function.

  • Community Member Profile Picture
    on at
    RE: Email body From Report Selection

    Thank You so much! Your lines of code are working but I still have a little hiccup. The email body have all the html tags. How can I remove or show body without html tags?

  • Verified answer
    I Gusti Made Ari Profile Picture
    3,594 on at
    RE: Email body From Report Selection

    you need to  create a new temp HTML file. select the word layout and use SAVEASHTML to save word layout file. The word layout file path then passed to email item Body file path.

    Standard code will be like below :

    ServerEmailBodyFilePath :=
    SaveReportAsHTML(TempBodyReportSelections."Report ID",RecordVariant,TempBodyReportSelections."Email Body Layout Code");
    FileManagement.BLOBImportFromServerFile(TempBlob,ServerEmailBodyFilePath);
    EmailItem.Body := TempBlob.Blob;
    BodyText := EmailItem.GetBodyText;
    EmailItem.SetBodyText(BodyText);

    Can also check below post by saurav  for the solution :

    saurav-nav.blogspot.com/.../microsoft-dynamics-nav-2017-email-from_21.html

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans