web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Emailing the PDF attachment in NAV 2018 AL language gives an error

(0) ShareShare
ReportReport
Posted on by 3,967

Hi,

I'm trying to send the Email with PDF file as an attachment in NAV 2018. I've used the following code

FileName:=FileManagement.ServerTempFileName('pdf');
REPORT.SAVEASPDF(50001,FileName,ContractsTable);

This code was automatically converted using TXT2AL utility. But it gives error in AL. Please guide.

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Andrey Baludin Profile Picture
    3,941 on at

    Microsoft docs tells next thing:

    Code that relies on temporary files must be rewritten to rely on InStream and OutStream types.

    Code that relies on permanent files must be rewritten to use another form of permanent storage.

    So, we can forget about FileManagement.ServerTempFileName in AL.

  • Olister Rumao Profile Picture
    3,967 on at

    So what you say is I've to create an Instream/Outstream which will take report (Temporary as PDF) and pass this stream to SMTP.AddAttachment method?

  • Suggested answer
    Andrey Baludin Profile Picture
    3,941 on at

    There is AddAttacmentStream function in SMTP codeunit (400), use it instead of AddAttachment.

    attstream.JPG

  • Verified answer
    Olister Rumao Profile Picture
    3,967 on at

    I've tried this and posted a blog.

    www.cloudfronts.com/workaround-to-report-saveaspdf-in-nav-2018

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans