Skip to main content

Notifications

Business Central forum
Suggested answer

Send Email from Custom Report Selection with Email body

Posted on by 6
Hi,
Problem to solve: /Get the email body as text from Report Selection- Email Body Custom Layout Description/

Process: 
I extended the /Report Selection - Sales/ by adding my own option to the enum. Called /GiftCard/

I was able to add a report ID and add an Email Body Custom Layout Description with no problem. We will be using this new option in multiple companies and each company have their own email body.

When sending an email we use /EmailMessage: Codeunit /Email Message/;/ and EmailMessage.Create()
This is the most basic structure of email we can use. 

We want to retrieve the Word layout from Report Selection and convert it to HTML and use that as the body. 

The First option we looked at was in Report Selection (Table: 77)- Procedure GetEmailBodyTextForCust()
Which (In Short) is OnPrem and save the file path on the server and makes use of another onPrem function
 REPORT.SaveAsHtml(ReportID, FilePath, RecordVariant);- Report.SaveAsHtml() is a built in function that we can't copy over
 
The second option we looked at was the Sales Order- Send Email, which led us to codeunit 8906 Email Editor, 
Here we have the WordTemplateToTextWizard that GetsDocumentAsText(), but this procedure us also a bit confusing. We cant seem to find where the Word document is retrieved from the Report Selection. We can se that it is used in the SetBody() procedure.

This is for a SAAS client, I would like to avoid onPrem procedures or copying procedures from Base to implement. 
So how does Microsoft do it in SAAS? or do they still use the OnPrem Procedures?

Thanks in advance

 
 
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 68,242 Super User 2024 Season 2 on at
    Send Email from Custom Report Selection with Email body
    Hi, I feel like they are still using OnPrem Procedures.
    For example,
    Sorry I haven't tested it in detail, you can try the following methods or events.
    table 9500 "Email Item" -> procedure GetBodyTextFromBlob() Value: Text
     
    Hope this helps.
    Thanks.
    ZHU
     

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,186 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,996 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans