Sending an e-mail from NAV through SMTP
NAV 2013 supports Simple Mail Transfer Protocol (SMTP), which makes mail sending easy and independent. Through SMTP, NAV will send mail directly to the exchange server. In the older version, when we used to send it through Outlook, it consisted of a more complex code. This recipe will show you how to configure and use that SMTP code.
Getting ready
Open the
RoleTailored client
; in the RTCSearch
box typeSMTP
, and choose the related link.Provide the SMTP server address and the server port.
Choose authentication type set by your IT department and, if required, provide credentials.
How to do it...
Start the development by creating a new codeunit from Object Designer.
Add the following global variables:
Name
Type
SubType
SMTPMailSetup
Record
SMTP Mail Setup
SMTP
Codeunit
SMTP Mail
Write the following code in the
OnRun
trigger of the codeunit:IF SMTPMailSetup.GET THEN BEGIN SMTP.CreateMessage('Rakesh Raul','YourE-mail@microsoft.com', ...