Well, we know that we can show word layout report into Email body while sending the email to our customers or partners or anybody from Business Central, but setting up the Email functionality or Document sending profile.

Here I am explaning how we can convert the Word layout report to text and add it into Email body as HTML.

Here we go

First we need to make an Wordlayout report (Docx) file it can be any report, I am showing the example here.

After selecting the word layout report we can write our code how to convert the word report file into Text and add into Email body as HTML.

procedure SendEMailtoCustomer(CustEMail: Text; CustNo: Code[20])
var
Cust: Record Customer;
EmailMessage: Codeunit "Email Message";
email: Codeunit Email;
base64: Codeunit "Base64 Convert";
InS: InStream;
EMailBody: text;
Outstrebody: OutStream;
DocRef: RecordRef;
FldRef: FieldRef;
begin
Clear(EMailBody);
Clear(ins);
Cust.get(CustNo);
DocRef.GetTable(Cust);
FldRef := DocRef.Field(Cust.FieldNo("No."));
FldRef.SetRange(Cust."No.");
if DocRef.FindFirst() then begin
Clear(TempBlob);
// Create new Outstream variable
TempBlob.CreateOutStream(Outstrebody);
// this is my Word layout report I have created new report and saving as HTML file, and sending this report in OutStream (Outstrebody)
report.SaveAs(report::"Customer Account Detail Email", '', ReportFormat::Html, Outstrebody, DocRef);
// CreateInstream function will read the Outstrebody varilable into create my Ins (Instream).
tempblob.CreateInStream(InS);
// ReadText function of Instream will read the text and convert it into our Text variable (Emailbody)
InS.ReadText(EMailBody);
// Here we are going to put the Emailbody (converted text) into Message with HTML as true (see the last parameter)
EmailMessage.Create(Cust."E-Mail", 'My Statement', EMailBody, true);
// Below code section is used to attached the PDF report as a attachment here.
Clear(TempBlob);
TempBlob.CreateOutStream(Outstrebody);
Report.SaveAs(Report::"Customer Account Detail", '', ReportFormat::Pdf, Outstrebody, DocRef);
tempblob.CreateInStream(InS);
EmailMessage.AddAttachment('Account Detail.pdf', 'application/pdf', base64.ToBase64(InS));
email.Send(EmailMessage);
end;
end;

Final output would be like this:

Emailbody

Emailbody