Question

I am sending a text only email using TIdMessage and TIdSMTP.

For the Body I use a simple concatenated string like

Body := SomeText + #13#10 +
          SomeOtherText + #13#10 +
          SomeMoreText + #13#10 +
          FinalText;

Anyway in the generated email some of the "#13#10" aren't ignored. I log the Body variable and I can see that the text goes to new line, anyway in the email this doesn't happen. The strange thing is that doesn't happen on every line but only on some lines.

Do you have an idea on why this happens? Can you suggest something to check for? Is there some possible confict between #13#10 and an text email body in some conditions?

UPDATE

After more investigation (thanks to your comments) I realized it is an Outlook visualization problem, anyway the problem is still not clear to me.

This is the body of the email opened in NotePad++ (I opened the msg file saved from outlook) where I show also line breaks (you can see #13#10 as CR LF. I highlighted in red and green the 2 line breaks that are problematic in outlook (but you can see that in NP++ they look like all the other linebreaks): Email body in NotePad++

The email in Outlook looks like this (please note that outlook says that the message has extra line breaks and that they hahve been removed, but he offers an option to restore them: EMail in Outlook displayin bad]

After choosing that option the email is ok: enter image description here

I don't understand why this happens only on some line breaks. Does this help you to understand the problem better?

Was it helpful?

Solution

You could try using IdMessage.NoEncode := True so that the Body will not be RCF 821 encoded.

Or better use modern encoding IdMessage.ContentType := 'text/html' and replace #13#10 with <br>

EDIT: This is an Outlook Express issue.

Look Here and Here. A workaround would be to add 2 empty characters to the beginning of each line of text in order to make Outlook not remove the breaks.


Note that Microsoft support also suggests using HTML format as a possible workaround with Outlook Express:

Method 2. Use HTML or Rich Text format You can use HTML or Rich Text formats when you create new items. Or you can change existing posts to these formats.

OTHER TIPS

It might be the email client stripping out some line breaks, if your ContentType is plain text.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top