Jigsaw Blog



NAV2009R2 DotNet SMTP Add-in

NAV 2009 R2 introduced a new data type - DotNet. Sounded like a good idea but was there any practical use for it? Yes there is.

We had a situation where a client wanted to email a large number reports in batch process. The most logical approach would be to use

  • SaveAsPDF for each report
  • the SMTP module built into Codeunit 400 - SMTP - to send each report

There are a few inherit problems with using Codeunit 400

  1. No exception handling
    This is a general C/Side issue - sight
    This was a real problem as the process would stop on an invalid email address. Validating the address will not solve this issue because while the address may be structurally correct when the SMTP client tries to send it will error if the address does not exist.
  2. Sending via an SMTP server is slow - a problem when you have thousands of emails to send

The answer was to

  • create a c# DotNet class (JigsawNAVEmail) that wraps System.Net.Mail
  • use this class via the new DotNet data type

In the JigsawNAVEmail class allows us to use additional delivery methods

  1. Via IIS drop folder
    Requires SMTP Mail to be setup on the IIS Server
  2. Via Specific drop folder

The advantage of using delivery via IIS is that "Send" simply creates a file on the local hard drive = fast. IIS SMTP then takes over and delivers the email. (We setup IIS to deliver via a smarthost being the clients Exchange Server)

There are two parts to this solution

  1. JigsawNAVEmail Class
  2. Code unit to wrap and expose the functions

Both of these are provided in the zip below. Use at your own risk.

Click here to download the source/example