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,959

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

  • Verified answer
    Olister Rumao Profile Picture
    3,959 on at
    RE: Emailing the PDF attachment in NAV 2018 AL language gives an error

    I've tried this and posted a blog.

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

  • Suggested answer
    Andrey Baludin Profile Picture
    3,941 on at
    RE: Emailing the PDF attachment in NAV 2018 AL language gives an error

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

    attstream.JPG

  • Olister Rumao Profile Picture
    3,959 on at
    RE: Emailing the PDF attachment in NAV 2018 AL language gives an error

    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
    RE: Emailing the PDF attachment in NAV 2018 AL language gives an error

    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.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans