Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)
Suggested answer

Error AddAttachment file on NAV2015

Posted on by 15

Hi,

I have a Dynamics Nav 2015 installed on a domain server. When I try sending a quote (or any other attachment for that matter) via email, it gives me an error on the AddAttachment function.

Microsoft Dynamics NAV
---------------------------

Attachment C:\ProgramData\Microsoft\Microsoft Dynamics NAV\80\Server\MicrosoftDynamicsNavServer$DynamicsNAV80M\users\default\TALIDA\EDMHILAL\TEMP\__TEMP__d14eb1d1b6254de3993bd2792f8a9495.tmp.pdf does not exist or can not be accessed from the program.
---------------------------
OK
---------------------------

The error is showing on this path location and on any another path on the server. although I have gave already a full permission on all the folders.

SMTP is setup correctly and used the test mail feature which was successful.

what do you think about this error?

*This post is locked for comments

  • ManishS Profile Picture
    ManishS 6,578 on at
    RE: Error AddAttachment file on NAV2015

    you need to download the pdf on client machine.

  • ahmadbarbar Profile Picture
    ahmadbarbar 15 on at
    RE: Error AddAttachment file on NAV2015

    The idea is that my code is working correctly on my local database NAV2016 but on the client server NAV2015 has showing the error.

  • ahmadbarbar Profile Picture
    ahmadbarbar 15 on at
    RE: Error AddAttachment file on NAV2015

    Hello Binesh,

    This is my code Dear,

    ServerAttachmentFilePath := '';

       ServerAttachmentFilePath := FileManagement.ServerTempFileName('pdf');

       SalesStatisticReport.SAVEASPDF(ServerAttachmentFilePath);

       CLEAR(SalesStatisticReport);

       IF NOT EXISTS(ServerAttachmentFilePath) THEN

         ERROR(ServerSaveAsPdfFailedErr);

       SMTPMail.AddAttachment(ServerAttachmentFilePath, 'Salesstatistic.PDF');

       SMTPMail.Send;

    The saving function is working correctly and my error is on Addattachment function.

  • ahmadbarbar Profile Picture
    ahmadbarbar 15 on at
    RE: Error AddAttachment file on NAV2015

    The location is correct dear.

  • ahmadbarbar Profile Picture
    ahmadbarbar 15 on at
    RE: Error AddAttachment file on NAV2015

    The file name has generated automatically from NAV and you can open it.

  • ManishS Profile Picture
    ManishS 6,578 on at
    RE: Error AddAttachment file on NAV2015

    You should check standard code for addattachment, there is change in the function, now it requires two parameter.

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Error AddAttachment file on NAV2015

    Hello Ahmad,

    Before attachment write some more line, see bellow code

    // Here FileNameWithPath and ToFille is a text variable, And FileMgt is a codeunit 419.

    //Now in ToFile upload your file as you doing, or see bellow.

    ToFile := FileMgt.UploadFileSilent('C:\TEMP\RUWMSP.pdf');

    //Now you have to download file from temp path

    FileNameWithPath := FileMgt.DownloadTempFile(ToFile); 

    // Finally pass the Variable FileNameWithPath in your AddAttachment function.  :)

  • Suggested answer
    Maneesha Profile Picture
    Maneesha 5,889 on at
    RE: Error AddAttachment file on NAV2015

    Ahmad Barbar ,

    i don't think this is the location that your file exactly stored right ?

    have you test mail with attachment ?

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Error AddAttachment file on NAV2015

    I think your file name has problem as it contains .tmp.pdf . This might me problem

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,113 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans