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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Creating an XML file or CSV file for Purchase Order using code and sending it to vendor's email address

(0) ShareShare
ReportReport
Posted on by 12

Hello All,

I have this requirement to fulfill where I have to create either csv file or xml of selected purchase order and that created file should be mailed to the e-mail of vendor presented in that purchase order.I have already created an action in purchase order called "Send Order to Vendor" but how can i write a code to create either csv file or xml file.

Any help will be appreciated

Thanks In Advance

*This post is locked for comments

I have the same question (0)
  • Tina Menezes Profile Picture
    2,582 on at

    Hi,

    You have to code in this way to create an csv or xml file.

      FileName:=FileManagement.ServerTempFileName('csv');

      PurchaseHeaderTable.RESET;

      PurchaseHeaderTable.SETRANGE("No.",PONumber);

      IF PurchaseHeaderTable.FINDFIRST THEN BEGIN

           REPORT.SAVEASEXCEL(405,FileName,PurchaseHeaderTable);

      END;

    Here FileManagement is a variable of type codeunit FileManagement and FileName is a variable of Text

    For attaching in xml format

    REPORT.SAVEASXML(405,FileName,PurchaseHeaderTable);

  • Sulav Thapaliya Profile Picture
    12 on at

    Thanks a lot Tina

    I will try this..

  • Suggested answer
    Marcellus Profile Picture
    2,735 on at

    Hi Sulav,

    Take a look at these two articles on MSDN:

    Walkthrough: Exporting Data from Tables to XML Documents

    Walkthrough: Exporting Data from Tables to CSV Files

    The two articles will show you how to build your xml port and how to develop a codeunit to execute them

    If you have not used XML ports before you may want to look at this too: https://msdn.microsoft.com/en-us/library/dd338846(v=nav.90).aspx

     Saurav Dhyani posted a very good article about sending smtp emails from NAV on his blog: https://saurav-nav.blogspot.co.uk/2017/05/microsoft-dynamics-nav-2017-email-from.html

  • Tina Menezes Profile Picture
    2,582 on at

    Hi,

    In addition to my previous answer, if you want to also know the procedure to send email with your .csv or .xml file of selected PO as an attachment, you can refer the below link of Saurav Dhyani.

    https://saurav-nav.blogspot.in/2013/08/send-mail-with-attachment-from-navision.html

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    You can use XMLPORT for exporting the data in required format

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans