How to Send SMTP mail from Navision Application

2 Steps to use it –
1. Setup the SMTP mail in Navision.
2. Use the functions avaliable in Codeunit 400 (SMTP Mail)
1. Setup the SMTP mail in Navision:
Go to Administration> IT administration > General Setup > SMTP Setup. The following screen will open –
You need a SMTP server address (IP or link). I have used my office SMTP server. If your SMTP server permits anonymous mailing, you can choose authentication as ‘Anonymous’ where you don’t need to mention any user id and password.
If your SMTP Server does not allow anonymous mailing, you need to choose authentication as ‘Basic’ and need to mention one valid User id and Password.

2. Use the functions available in Codeunit 400 (SMTP Mail) :

Once the setup is done, you can start mailing using the functions available in SMTP mail codeunit.
a) Take a new form and take a command button on it. On clicking of that button the mail will be send (Just for the example)
b) Take a global variable ‘SMAIL’ of data type ‘Codeunit’ and subtype ‘SMTP mail’ codeunit. This will give you the access to the functions available in that codeunit.
c) Now the actual code. Write the following code on ‘On Push’ trigger of the command button
SMAIL.CreateMessage(‘Snehanshu’,’’,’’,’Warning – Inventory’, ‘Item 50005 has a inventory below minimum inventory level’,FALSE);
[Syntax for the Createmessage function – Createmessage([sender’s name] ,[sender’s id],[recipient’s id or ids],[subject] ,[body line] ,[html formatted or not]]
SMAIL.AddAttachment(‘d:Sales Invoice.xlsx’);
MESSAGE(‘mail send’);
That’s it. Now click on the command button, and the mail will be sent to the recipients.
1. There can be multiple recipients. Just put them as comma separated text in the recipient parameter.
2. You can add more body lines using ‘AppendBody’ function.
3. You can also mark a CC or BCC copy of the mail using ‘AddCC’ ‘AddBCC’ functions.
If you are not sure about the SMTP server, just search in google how to use, rediffmil, Gmail or Hotmail or any other mailing system as your smtp server.

10 Replies to “How to Send SMTP mail from Navision Application”

    1. Which version of NAV you are using? You should be able to change the Authentication method unless somebody had written a code to force it to remain always ‘basic’. You can run the the form 409 or page 409 to check if it is allowed or not. If it is not allowed, then check with your service partner if the same is restricted for any particular reason or not.

  1. Hi again,
    this error is fixed.but got new one saying “The SMTP mail system returned The following error:(0x8004020E):The server rejected the sender address.The server responce was: 530 5.7.0 Must issue a STARTTLS command first. nv10sm3635088pbb.49”

    What to do…?

    Thanks in Advance

  2. Hello Export,
    I followed ur instructions,but i am getting an error like “The SMTP mail system returned the following error:(0x80040213):The transport failed to connect to the server.”
    So what do to do…?
    Thanks In Advance.
    NAV Developer

  3. Dear All,
    I have a solution for SMTP Server as and it is working Successfully.
    reach me at

    Sami mohammed
    Navision technical Consultant.
    Microsoft Certified Professional.

  4. Bobby, what you have written is actually will use Outlook object model not smtp mail system.

    What Snehanshu said is correct for sending SMTP mail.

  5. 2 ways we can use smtp mail in nav
    1) In administration setup we can configure smtp mail and this can be used as a default mail and is used for outlook integration
    2) Name DataType Subtype Length
    Mail Codeunit Mail
    If the out look is configured with the smtp mail then
    Mail.NewMessage(, CCName,Message1 , Message1, AttachFileName, FALSE );
    then the mail will go to from the system configured mail.

    1. I was puzzeld on how to send an email to multiple recipients then I figured out you can create a Global Variable Text and substitute email address for the Text constant.

      Name Text

      (‘Event’,’’,TEXT001,’New Item ‘ + “No.” + ‘ has been created by ‘ + NewUser,’Item ‘ + NewItem + ‘ – ‘ + NewDesc,FALSE);


This site uses Akismet to reduce spam. Learn how your comment data is processed.