SMTP Email Issue

Hi All,

I am getting following error while sending email from NAV5 (on SQL Server) using SMTP. I am using GMAIL for sending emails and it uses port 587. For providing Port No. as parameter, I have updated the objects as described in Hot Fix (knowledge artcile KB981354 https://mbs2.microsoft.com/Knowledgebase/KbDisplay.aspx?scid=kb$EN-US$981354&wa=wsignin1.0):

The SMTP mail system returned the following error: 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. va6sm42890097igc.6

What should be done for resolving this issue?

Thanks

Hi,

Did you use your gmail account for authentication?

Was the from e-mail address you used a gmail address?

Try both if you haven’t already.

Hi Dhanraj,

I feel antivirus or firewall blocking the SMTP mail. Try after unistalling or disabling the antivirus.

hey dhan,

did you found a solution for the issue, cause it does not look like a firewall or antivirus issue to me.

Its something to do with the SSL or TLS.

SMTP setting, click the “Secure Connection” and make sure your server is enabled with SSL

Its version 2009 R2, the secure connection is in 2013 onwards!

OK found another KB where the secure connection is available.

But now I have this new error,

This message is for c\AL programmers:
Could not create an instance of the OLE control or Automation server identified by
GUID={68AEAA7B-9523-3511-AF5F-F2381D2C6F04}7.3{F9DAE2A4-D2F8-37C3-86D5-E4FFE166D860}:‘Microsoft Navision Mail’.SmtpMessage.
Check that the OLE control or Automation server is correctly installed and registered.

I tried on three different machine.
I had registered the dll file but still this error is coming.

Did I miss something.

Did you register it with both regasm.exe and gacutil.exe?

I did it with regasm.

gacutil.exe ? it gave me error of unrecognized in cmd prompt.

8272.Capture.JPG

Still same error.

At this point, if you enter in design of codeunit SMTP Mail, is the “Mail” variable subtype properly recognized or it shows “Unknown Automation Server.Unknown Class”?

Its properly reconized as Microsoft.Navision.Mail.Smtpmessage.

I have two versions in the automation list as 1.0(base installed) and 7.3 (Its a KB related dll )

6153.Capture.JPG

Codeunit 400 SMTP Mail

OnRun()

CreateMessage(SenderName : Text[100];SenderAddress : Text[50];Recipients : Text[1024];Subject : Text[200];Body : Text[1024];HtmlFormatt
IF Recipients <> ‘’ THEN
CheckValidEmailAddresses(Recipients);
CheckValidEmailAddresses(SenderAddress);
SMTPMailSetup.GET;
SMTPMailSetup.TESTFIELD(“SMTP Server”);

CLEAR(Mail);
IF ISCLEAR(Mail) THEN
CREATE(Mail,TRUE,TRUE);

Mail.FromName := SenderName;
Mail.FromAddress := SenderAddress;
Mail.“To” := Recipients;
Mail.Subject := Subject;
Mail.Body := Body;
Mail.HtmlFormatted := HtmlFormatted;

Send()
WITH SMTPMailSetup DO
Result :=
Mail.Send(
“SMTP Server”,“SMTP Server Port”,Authentication <> Authentication::Anonymous,“User ID”,Password,“Secure Connection”);

Mail.Dispose;
CLEAR(Mail);
IF Result<>’’ THEN
ERROR(Text003,Result);

AddRecipients(Recipients : Text[1024])
CheckValidEmailAddresses(Recipients);
Result := Mail.AddRecipients(Recipients);
IF Result <> ‘’ THEN
ERROR(Text003,Result);

AddCC(Recipients : Text[1024])
CheckValidEmailAddresses(Recipients);
Result := Mail.AddCC(Recipients);
IF Result <> ‘’ THEN
ERROR(Text003,Result);

AddBCC(Recipients : Text[1024])
CheckValidEmailAddresses(Recipients);
Result := Mail.AddBCC(Recipients);
IF Result <> ‘’ THEN
ERROR(Text003,Result);

AppendBody(BodyPart : Text[1024])
Result := Mail.AppendBody(BodyPart);
IF Result <> ‘’ THEN
ERROR(Text003,Result);

AddAttachment(Attachment : Text[260])
IF Attachment = ‘’ THEN
EXIT;
IF NOT EXISTS(Attachment) THEN
ERROR(Text002,Attachment);
Result := Mail.AddAttachments(Attachment);
IF Result <> ‘’ THEN
ERROR(Text003,Result);

CheckValidEmailAddresses(Recipients : Text[1024])
IF Recipients = ‘’ THEN
ERROR(Text001,Recipients);

s := Recipients;
WHILE STRPOS(s,’;’) > 1 DO BEGIN
CheckValidEmailAddress(COPYSTR(s,1,STRPOS(s,’;’) - 1));
s := COPYSTR(s,STRPOS(s,’;’) + 1);
END;
CheckValidEmailAddress(s);

CheckValidEmailAddress(EmailAddress : Text[250])
IF EmailAddress = ‘’ THEN
ERROR(Text001,EmailAddress);

IF (EmailAddress[1] = ‘@’) OR (EmailAddress[STRLEN(EmailAddress)] = ‘@’) THEN
ERROR(Text001,EmailAddress);

FOR i := 1 TO STRLEN(EmailAddress) DO BEGIN
IF EmailAddress[i] = ‘@’ THEN
NoOfAtSigns := NoOfAtSigns + 1;
IF NOT (
((EmailAddress[i] >=‘a’) AND (EmailAddress[i] <=‘z’)) OR
((EmailAddress[i] >=‘A’) AND (EmailAddress[i] <=‘Z’)) OR
((EmailAddress[i] >=‘0’) AND (EmailAddress[i] <=‘9’)) OR
//New Code
((NoOfAtSigns = 0) AND (EmailAddress[i] IN [’!’,’#’,’$’,’%’,’&’,’’’’,
‘*’,’+’,’-’,’/’,’=’,’?’,
‘^’,’’,’`’,’.’,’{’,’|’,
‘}’,’~’])) OR
((NoOfAtSigns > 0) AND (EmailAddress[i] IN [’@’,’.’,’-’,’[’,’]’])))
//Old Code
//(EmailAddress[i] IN [’@’,’.’,’-’,’
’]))
THEN
ERROR(Text001,EmailAddress);
END;

IF NoOfAtSigns <> 1 THEN
ERROR(Text001,EmailAddress);