Our customer is using BC23.1
When I am trying to send an email with attachment (PDF), I am getting this error
"The Tenant Media does not exist. Identification fields and values: ID='{00000000-0000-0000-0000-000000000000}"
The error is generated in this line when I do the attachment:
EmailMsg.AddAttachment(FileNameForEmail, 'application/pdf', iStr);
where, iStrm is a variable of Type InStream;
I checked iStr has value,
and its generated from a BC Report,
oStrm := tempBlobcu.CreateOutStream();
if CustomerStatement.SaveAs('', ReportFormat::Pdf, oStrm) then begin
iStrm := tempBlobcu.CreateInStream();
Any suggestion would be appreciated.
Thanks.
0
Answers
https://forum.mibuso.com/discussion/76181/save-report-as-pdf-and-send-as-e-mail
Good luck!
D365 Business Central Solutions Architect
BC AL/NAV C/AL Developer
BC Repositories.com
I tried the solution, I am now getting a different error.
This time the error is:
Microsoft.Dynamics.Nav.Runtime.NavInStream variable not initialized.
This error occurred when I tried to convert the iStream.
txtB64 := converter_.ToBase64(iStr, true);
EmailMsg.AddAttachment(FileNameForEmail, 'application/pdf', txtB64);
D365 Business Central Solutions Architect
BC AL/NAV C/AL Developer
BC Repositories.com
oStrm := tempBlobcu.CreateOutStream();
if CustomerStatement.SaveAs('', ReportFormat::Pdf, oStrm) then begin
iStrm := tempBlobcu.CreateInStream();
After correcting this, now I am back to this error:
The Tenant Media does not exist. Identification fields and values: ID='{00000000-0000-0000-0000-000000000000}'
Is there any extension that Business Central Require to do attachments or for handling Media? or is there any specific configuration related to email attachments?
Thanks.
I was doing this before creating the Email.
oStrm := tempBlobcu.CreateOutStream();
if CustomerStatement.SaveAs('', ReportFormat::Pdf, oStrm) then begin
iStrm := tempBlobcu.CreateInStream();
gtFileName := FileMgt.InstreamExportToServerFile(iStrm, 'PDF');
and that initialized the value of iStrm (I guess).
After Commenting this line, the attachment started working.