Just a quick post here serving as shortcut for implementing Microsoft Navision Mail.SmtpMessage in older databases. All it requires is these objects:
- Table 409 SMTP Mail
- Form 409 SMTP Mail
-
Codeunit 400 SMTP Mail
And of course an updated license file for the customer, that adds the permissions for the new 5.0 objects. If they are not on the v5 executables they also need to install the “Microsoft.Navision.Mail.dll” automation control. I have created a small package here that is a selfextracting rar file, that automatically installs the component into the Global Assembly Cache.
Here are the objects (from 5.0SP1):
|
|
download: SMTP objects (7.11KB) added: 29/06/2010 clicks: 136 description: Table 409 SMTP Mail Form 409 SMTP Mail Codeunit 400 SMTP Mail |
And the Mail automation installer:
|
|
download: Microsoft.Navision.Mail (156.94KB) added: 29/06/2010 clicks: 169 description: External component for SMTP mail in Dynamics NAV. Updated with KB981354, to support SMTP port selection. |
Usage is very simple:
SMTP.CreateMessage(SenderName,SenderAddress,Recipients,Subject,Body,HtmlFormatted); SMTP.Send();
you will see methods for AddRecipients, AddCC, AddBCC, AppendBody and AddAttachment. The component also supports HTML in the body section.
Update 6/29/2010:
I just received a message from my danish colleague Steffen Brandt, that a hotfix is available from Microsoft, that allows you to change the standard SMTP port 25. The KB981354 has the information. I will update the download section tomorrow, so it has the latest DLL’s and fob’s.
Hotfix code changes:
Add column 6 in the SMTP Mail Setup table(409) as follow:
...
{ 6 ; ;SMTP Server Port ;Integer ;InitValue=25; }
...
4. Add the SMTP Server Port field in the SMTP Mail Setup form(409) as follow:
...
{ 14 ;TextBox ;3850 ;1540 ;5500 ;440 ;Name=<SMTP Server Port>;
ParentControl=1;
InPage=0;
DecimalPlaces=0:0;
NotBlank=Yes;
Numeric=Yes;
SourceExpr="SMTP Server Port";
MinValue=1 }
{ 15 ;Label ;440 ;1540 ;3300 ;440 ;ParentControl=14; }
...
5. Change the code in the SMTP Mail codeunit(400) as follows:
Existing code 1
...
Mail@1000 : Automation "{68AEAA7B-9523-3511-AF5F-F2381D2C6F04} 1.0:{F9DAE2A4-D2F8-37C3-86D5-E4FFE166D860}:'Microsoft Navision Mail'.SmtpMessage";
...
Replacement code 1
...
Mail@1000 : Automation "{68AEAA7B-9523-3511-AF5F-F2381D2C6F04} 7.0:{F9DAE2A4-D2F8-37C3-86D5-E4FFE166D860}:'Microsoft Navision Mail'.SmtpMessage";
...
Existing code 2
...
Mail.Send(
"SMTP Server",Authentication <> SMTPMailSetup.Authentication::Anonymous,"User ID", Password);
...
Replacement code 2
...
Mail.Send(
"SMTP Server",Authentication <> Authentication::Anonymous,"User ID",Password,"SMTP Server Port");
...


I saw this blog through Facebook (someone posted it). After reading, I then clicked “Like” and shared it.
This is my first time I have visited here. I found a lot of interesting information in your blog. From the volume of comments on your posts, I guess I am not the only one! keep up the good work.
I am using this, but could not send any smtp (smtp.gmail.com). It gives me following error message :
“ The SMTP mail system returned the folloeing error message: The SMTP server requires a secure connection or the client was not Authenticated. The server response was:5.7.0 Must issue a STARTTLS command first. b11sm2417142rvf.10 “
Kindly help me to solve it ?
Thank you.