Hi
I have a codunit where I wanted to create a report as PDF and attached it to the email. It is a custom table and custom report.
can anyone suggest a mistake here?
//-----------------------------------------------
Hi
I have a codunit where I wanted to create a report as PDF and attached it to the email. It is a custom table and custom report.
can anyone suggest a mistake here?
//-----------------------------------------------
Saurav,
I am using following code to generate pdf , then attach and send email. It is working fine. But problem is few pdf are corrupted. But when I send these pdf individually (not as bulk) then it is working. Again, corrupted file is working fine in all pdf readers except acrobat reader..
if SalesInvoiceHdr.FindFirst() then
repeat
clear(RecRef);
SalesInvHdr.Reset();
SalesInvHdr.SetRange("No.", SalesInvoiceHdr."No.");
if SalesInvHdr.FindFirst() then
RecRef.GetTable(SalesInvHdr);
tempBlob.CreateOutStream(outStreamReport);
tempBlob.CreateInStream(inStreamReport);
body := '';
emailMsg.Create('shan.abeywickrema@abcsd.com.au', 'Your invoice ' + SalesInvHdr."No." + ' has been processed', body, true);//SalesInvoiceHdr."Sell-to E-Mail"
Report.SaveAs(Report::"Posted Proforma Invoice", '', format::Pdf, outStreamReport, recRef);
//txtB64 := cnv64.ToBase64(inStreamReport);
emailMsg.AddAttachment('Sales Invoice ' + SalesInvHdr."No." + '.pdf', 'pdf', inStreamReport);
email.Send(emailMsg);
until SalesInvoiceHdr.Next() = 0;
Do you find any issue with this code?
hi, try this code:
DataTypeMgt.GetRecordRef(mailRec,RecordRef); //codeunit "Data Type Management" AttachmentTempBlob.CreateOutStream(OutStr); Report.SaveAs(ReportID, '', ReportFormat::Pdf, OutStr, RecordRef); AttachmentTempBlob.CreateInStream(InStr); EmailMessage.AddAttachment(Filename, 'PDF', InStr); EmailMessage.Create("Send to", Subject, 'Price Notification'); Email.Send(EmailMessage, Enum::"Email Scenario"::"Gas Price Email");
Hi,
Hope this helps.
Thank you
I wanted to send a record as recordset to report 50100. it is a single record report, that is being formatted in the report, which is our attachment.
this following syntax may not work, last time I tried
Report.SaveAs(Report::"Standard Sales - Invoice", ReportParameters, ReportFormat::Pdf, OutStr);
Hi hafiz,
this is the simple code, you test and modify it according to your requirements
ReportParameters := ReportExample.RunRequestPage(); TempBlob.CreateOutStream(OutStr); Report.SaveAs(Report::"Standard Sales - Invoice", ReportParameters, ReportFormat::Pdf, OutStr); TempBlob.CreateInStream(InStr); EmailMessage.Create('youremail@gmail.com', 'This is the subject', 'This is the body'); EmailMessage.AddAttachment('FileName.pdf', 'PDF', InStr); Email.Send(EmailMessage, Enum::"Email Scenario"::Default);
Hope it helps
Regards
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156