Carriage Return CrLF into a text variable

Hi,

I have a local variable MsgBody (text 260) I like to insert some text into this variable to insert it on the body of a mail in two lines.

I’ve try this code

MsgBody := 'Course de : ’ + Account + ‘’; MsgBody := MsgBody + 'Remarque : ’ + Remarques

But the result is (one line): Course de : NBA\Remarque : non facturé I’ve test ‘\’ and ‘/’ and ‘//’ but it’s not the good combination.

Can you help me?

Thanks Luc

The \ is only recognized as a line break within C/AL. To force line breaks in text inserted into other applications, you need to declare two variables of type char: VAR cr: Char; VAR lf: Char; and assign them the appropriate ASCII values: cr := 13; lf := 10; You can then concatenate these variables into your message text. Depending on your operating system, you might have to try if you need a CR, a CR/LF or a LF [;)]

Hi, 1. Define two variable of type CHAR. LF CHAR; CR CHAR; 2. Assign value to these variables LF := 10; CR := 13; 3. MsgBody := ‘Course de: ’ + Account + FORMAT(CR,0,’’) + FORMAT(LF,0,’’); MsgBody := MsgBody + 'Remarque : ’ + Remarques ; This would solve your problem.

I have searched all 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.[8o|] 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. It is a single line. Here is the code I am using:

Mail.Body := FORMAT(cust.“No.”) + FORMAT(CR,0,’’) + FORMAT(LF,0,’’) +
FORMAT(cust.Name) + FORMAT(CR,0,’’) + FORMAT(LF,0,’’) +
FORMAT(cust.“Phone No.”) + FORMAT(CR,0,’’)+FORMAT(LF,0,’’) +
(‘Your order request has been accepted.’);

Here is the email output:

A005 Alfred-Almond Central School (607)276-2961 x209 Your order request has been accepted.

I am using SMTP mail. Any help would be greatly appreciated!

Are you using the Mail codeunit (397) or SMTP Mail codeunit (400)? The first has a function AddBodyLine, the latter AppendBody. Have you tried those?

I am using the SMTP Mail Codeunit. Yes I have tried the AppendBody function as well. Still the same result. You can understand my frustration?

dont use CHAR use text like this:

Name DataType Subtype Length
CRLF Text 2

CRLF := ’ ';
CRLF[1] := 13;
CRLF[2] := 10;

test := ‘This is line 1’ + CRLF + ‘This is line 2’;

I feel really stupid now that I figured out my problem! I had HTML formatted set to TRUE.[:$] You live and you learn.