Why, in some conditions, an email sent with idSMTP does not fit a new line?

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

For Body I use a simple concatenated string like

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

In any case, some of " #13#10 " are not ignored in the generated message. I register the Body variable, and I see that the text goes to a new line, somehow this does not happen in the email. It is strange that this does not happen on every line, but only on some lines.

Do you have an idea why this is happening? Can you suggest something to check? Is there any possible conflict between #13#10 and the text body in some conditions?

UPDATE

After further investigation (thanks to your comments), I realized that this is an Outlook visualization issue, as the issue is still not clear to me.

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

Email in Outlook looks like this (note that Outlook says that the message has additional line breaks and that they are deleted, but it offers the option to restore them: EMail in Outlook displayin bad]

After selecting this option, the letter is in order: enter image description here

I do not understand why this only happens on some line breaks. Does it help you better understand the problem?

+4
source share
2 answers

You can try using IdMessage.NoEncode := True so that the body is not RCF 821 encoded.

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

EDIT: This is a problem with Outlook Express.

Take a look here and here . A workaround would be to add 2 blank characters to the beginning of each line of text so that Outlook does not remove the breaks.


Please note that Microsoft support also suggests using HTML as a possible workaround in Outlook Express:

Method 2. Use HTML or Rich Text format You can use HTML or formatted text formats when creating new elements. Or you can modify existing posts in these formats.

+6
source

Perhaps the email client will remove some line breaks if your ContentType is plain text.

+1
source

Source: https://habr.com/ru/post/1391456/


All Articles