Skip to main content

Microsoft Dynamics NAV 2017 - Email From NAV Part 3.

Hi Readers,

Let's continue what we are discussing from Last two weeks.

To understand the content of this article and use the pattern we are about to discuss in this article you need to go through old articles.

If you haven't read the Part 1 and Part 2 below are the links for same.

Part 1 - Send Email from Navision using a Pattern provided by Microsoft in New version.

Part 2 - Develop a Word Layout for Sales Shipment Report.

In this last article, we will discuss how to use the Pattern & Word Layout for sending an Email.

The idea is Simple - Using word Layout for the Email Body and then use Email Pattern to send Email.

Without Further Delay, let's discuss how we can configure & customize same in NAV 2017.
Thanks to Mohamed Zayed and hope this solves your issue.

** What we are customizing is already part of standard NAV. The article is just for an explanation how to customize if required to be added in some other NAV areas.

1. As we discussed in Part 2 we can have multiple word layout for the same report. These Layouts can be used for other usages than sending the email. So somewhere we need to setup which of the multiple layouts should be used for Emailing from NAV.

Microsoft Have added word layout selection in Report Selections. As shown below I will select the word layout that we created in Last Post.


2. Now Let's add some code for the new pattern that we want to use. New Function Name is SendSalesShipment which accept the record and returns Email is Sent or Not.

Functions Do Pre-Check, we can add more if required. After that, it uses the same Pattern as in Article 1.
While using pattern we use three Functions, shown below -
a.  Get Report ID and Word Layout Code to be used.
b.  Generate Email Attachment as PDF.
c.   Generate Email Body.

After Doing all this, Function sends an email and return if the email is sent.


3. So What these functions Do?

a. GetReportIDandLayoutCode - 
    This Function looks up of Report Selection table for the Shipment Report and get the report id and also the Layout code. 

b. GenerateDocumentEmailAttachment - 
     This function creates a new pdf file, and use SAVEASPDF using the Report ID from the first function and then exit the File Path for attachment. 

c. GenerateShipmentEmailBody - 
    This function creates a new temp HTML file. select the word layout and use SAVEASHTML to save word layout file. The word layout file path is sent back to the pattern function which is used to pass to the Body File Path.


4. Add a function in Sales Shipment Page for Sending Email.


5. Here is the Email that is sent from NAV.



Hope it helps.

Let me know if it makes sense there are so many additional features in this pattern that I would like to explain if this article helps my readers.

Waiting for your reply.

You can download the codeunit from OneDrive.

File Name- Microsoft Dynamics NAV 2017  - #SauravNAV_Email_Pattern_V2.0

Let me know your views.

Regards,
Saurav Dhyani

Comments

  1. Hi Saurav,

    The email in outlook shows html tags. How can I remove them?

    Thanks,
    Umair

    ReplyDelete
    Replies
    1. Umair,
      Are you using a custom Email Template developed by you. I think its a problem in coding that.
      It works great when i use it in custom also.

      Delete
  2. Hi Saurav,
    Interesting topic.
    Unfortunately links to Part 1 and 2 is not working.
    Also I do have a question. If Client wants to use plain text previously stored as a BLOB for the e-mail body instead of predefined Layout, could you advice nice and elegant way how to do it. The plain text also contains placeholders, that must be populated with values before sending e-mail.

    ReplyDelete
    Replies
    1. Part 1 and 2 are working now.
      Yes its possible, but I will have to setup a NAV 2017 environment. You can store it in blob, then extract and convert placeholders to value.

      Delete

Post a Comment

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.

Error After Restore SQL Backup of NAV 2013 Database

Hi all, we are facing a conman issue during restoring a SQL Database backup restored for NAV 2013. While Trying to run object from Object Designer we get below listed error (even the service is configured properly) - --------------------------- Microsoft Dynamics NAV Development Environment --------------------------- There are no NAV Server instances available for this database. You must ensure that a NAV Server instance is running and is configured to use the database before you perform this activity. --------------------------- OK    ---------------------------