web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Verified answer
    I Gusti Made Ari Profile Picture
    3,600 on at

    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

  • Community Member Profile Picture
    on at

    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?

  • Community Member Profile Picture
    on at

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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans