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

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searchi...

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.