Hello everyone! I have searched the forums and I know this topic has been discussed a few times. The problem is that I have tried every suggestion I have come across and nothing is working. ](*,) I have defined two variables, CR and LF, as type char. I give them the ASCII values 13 and 10, respectively. When my code is run and the email is generated, there are no carriage returns in the emails. Here is the code I am using:
Mail.Body := FORMAT(cust."No.") + FORMAT(CR,0,'<CHAR>') + FORMAT(LF,0,'<CHAR>') +
FORMAT(cust.Name) + FORMAT(CR,0,'<CHAR>') + FORMAT(LF,0,'<CHAR>') +
FORMAT(cust."Phone No.") + FORMAT(CR,0,'<CHAR>')+FORMAT(LF,0,'<CHAR>') +
('Your order request has been accepted.');
I am using SMTP mail. Any help would be greatly appreciated!
Regards,
Tanya
0
Comments
test := 'This is line 1' + CRLF + 'This is line 2';
Type conversion is not possible because 1 of the operators contain an invalid type.
Code + Char
My modified code:
Mail.Body := cust."No." + CR + LF +
cust.Name + CR + LF +
cust."Phone No." + CR + LF +
('Your order request has been accepted.');
If I use FORMAT(cust."No.") + CR + LF + , I receive the following error:
Type conversion is not possible because 1 of the operators contain an invalid type.
Text + Char
Well the CRLF needs to be a string not a char.
Here is some code from a working solution:
Name DataType Subtype Length
CRLF Text 2
CRLF := ' ';
CRLF[1] := 13;
CRLF[2] := 10;
Then you can just add CRLF to the text string.
How else would you do it?
Sorry I missread that. So make it one text variable of len 2.
Name DataType Subtype Length
CRLF Text 2
CRLF := '';
CRLF[1] := 13;
CRLF[2] := 10;
Mail.Body := FORMAT(cust."No.") + CRLF +
FORMAT(cust.Name) + CRLF +
FORMAT(cust."Phone No.") + CRLF + CRLF +
('Your order request has been accepted.');
Still no luck.
Anyway the code above I copied from a client that has been using it for many years without a problem, so not sure what the issue is.
You're right. I only need the FORMAT function on cust."No." because it is a code.
It was:
ch13 := 13;
lf10 := 10;
EXIT(FORMAT(lf10) + FORMAT(ch13));
This stopped working in NAV2017 with Outlook 2016.
So I used David's solution:
CRLF[1] := 13;
CRLF[2] := 10;
EXIT(CRLF);
It works again.
Tino Ruijs
Microsoft Dynamics NAV specialist