Options

SMTP Mail codeunit with SAVEASPDF

Alex_ChowAlex_Chow Member Posts: 5,063
edited 2011-05-19 in NAV Three Tier
Hi,

I've created a process to automatically send an e-mail to each customer ship-to. The e-mail also has a report that I've created using the SAVEASPDF function so the report can be sent as an attachment.

I can send the e-mail without problems, but I can't attach the pdf file. The code I have written so far is:
ToFile := DELCHR(ShiptoAddress."Customer No." + FORMAT(WORKDATE),'=','/\:.,') + '.pdf';
FileName := TEMPORARYPATH + ToFile;
REPORT.SAVEASPDF(REPORT::"My Report",FileName,ShiptoAddress);
ToFile := ReportHelper.DownloadToClientFileName(FileName, ToFile);

<The code to write the send to, body, etc>

Mail.AddAttachment(ToFile);
Mail.Send();

The ReportHelper codeunit is from Claus' blog found here:
http://blogs.msdn.com/b/nav-reporting/a ... -2009.aspx

I checked codeunit 397 (Mail) that the blog is using. It seems to convert the link to the file with this code in the codeunit:
IF AttachFileName <> '' THEN BEGIN
  BSTRConverterAttachFileName.ResetBSTR;
  BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileName);
  OAttachments := OSendMail.Attachments;
  OAttachment := OAttachments.Add(BSTRConverterAttachFileName);
END;

Does anyone know how I can add the attachment using SAVEASPDF using the SMTP Mail (codeunit 400) codeunit?

Answers

Sign In or Register to comment.