The Email address " " is invalid

I create purchase indent in NAV 13 R2 at the time of clicking Approve indent document I got a error message Like The Email address " " is invalid .i debug the smtp mail code Unit also but I didn’t get the solution plz help.

IF Recipients = ‘’ THEN
ERROR(Text001,Recipients);

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

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
ELSE
IF EmailAddress[i] = ’ ’ THEN
ERROR(Text001,EmailAddress);
END;

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

In what codeunit is NAV stoping with the error?

SMTP Mail 400

It seems that is trying to send an email with no address. You have to look for the process that is calling CU 400.

All users in approval processes have email assigned in NAV?

How can i check all the users have email assigned in NAV?

In the user card, contact email in general section or in user setup, email.

Every user have email in user setup

When you debug the error, what process is calling CreateMessage from CU 400? If you could trace the calling of CreateMessage function, you could see the moment is getting a blank email.

IF Recipients <> ‘’ THEN
CheckValidEmailAddresses(Recipients);
CheckValidEmailAddresses(SenderAddress);
SMTPMailSetup.GET;
SMTPMailSetup.TESTFIELD(“SMTP Server”);
IF NOT ISNULL(Mail) THEN BEGIN
Mail.Dispose;
CLEAR(Mail);
END;
SendResult := ‘’;
Mail := Mail.SmtpMessage;
Mail.FromName := SenderName;
Mail.FromAddress := SenderAddress;
Mail.“To” := Recipients;
Mail.Subject := Subject;
Mail.Body := Body;
Mail.HtmlFormatted := HtmlFormatted;

I keep the Toggle Mark on First Line then It will enter in to the Function called CheckValidEmailAddresses() then it checks the conditions one by one then Finally it showing the Error The Email Address " " is invalid.

You have to see to the call function stack to see with process has called that function. In that place you will probably find why the email is blank when calling to CU 400 function.

Window.OPEN(‘Sending mail…’ + EmailText);
Window.UPDATE(100, EmailReceiverID);

Subject := 'Indent Approved: ’ + FORMAT(“Document No.”);
Body := ‘’;

UserSetup.RESET;
IF NOT UserSetup.GET(UPPERCASE(USERID)) THEN
ERROR(‘User Setup not found for the User ID %1.\Please Contact to System Administrator…’, UPPERCASE(USERID))
ELSE
UserSetup.TESTFIELD(Name);

CLEAR(SMTP);
SMTP.CreateMessage(UserSetup.Name, UserSetup.“E-Mail”, EmailReceiverID,Subject, Body, TRUE);
SMTP.AppendBody(‘Dear Sir,’);
SMTP.AppendBody(’
’);
SMTP.AppendBody(‘Indent No. ’ + “Document No.” + ’ has approved. Please start Procurement activity.’);
SMTP.AppendBody(’



’);

SMTP.AppendBody(’’);
SMTP.AppendBody(’’);
SMTP.AppendBody(‘’);
SMTP.AppendBody(‘’);
SMTP.AppendBody(‘’);
SMTP.AppendBody(‘’);
SMTP.AppendBody(‘’);
SMTP.AppendBody(‘’);
SMTP.AppendBody(’’);
SMTP.AppendBody(’’);

The Call function is in the table

Item Code Item Description Requested Quantity Requested Date Available Stock Remarks

As I can see, there are some email field in blank in tabla user setup:

SMTP.CreateMessage(UserSetup.Name, UserSetup.“E-Mail”, EmailReceiverID,Subject, Body, TRUE);

There is No blank email field in user setup ji.but it showing the same error

If you use UserSetup.TESTFIELD(“E-Mail”) then you will know which user it is where the email is missing.

The TESTFIELD (“E-Mail”) Is fine,but Still its raising the Error

Then the problem is recipients email. Where do you get EmailReceiverID from? If user email is fine, then this var is blank.

IndentMail(EmailReceiverID : Text)
Window.OPEN(‘Sending mail…’ + EmailText);
Window.UPDATE(100, EmailReceiverID);

Subject := 'Indent Approved: ’ + FORMAT(“Document No.”);
Body := ‘’;

in the Local Variables Var Field is showing Blank for the Indentmail Function.

You have to look at IndentMail function call, the parameter is blank and it must be an email account.