为什么在某些情况下,使用idSMTP发送的电子邮件无法正常进入新行?(Why in some conditions an email sent with idSMTP doesn't go

系统教程 行业动态 更新时间:2024-06-14 17:04:03
为什么在某些情况下,使用idSMTP发送的电子邮件无法正常进入新行?(Why in some conditions an email sent with idSMTP doesn't go properly to new line?)

我正在使用TIdSMTP和TIdSMTP发送纯文本电子邮件。

对于Body我使用一个简单的连接字符串

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

无论如何,在生成的电子邮件中,一些“ #13#10 ”都不会被忽略。 我记录Body变量,我可以看到文本转到新行,无论如何在电子邮件中这不会发生。 奇怪的是,不是每一行都会发生,而只是在某些线路上发生。

你知道为什么会这样吗? 你能建议检查一下吗? 在某些情况下, #13#10和文本电子邮件正文之间是否存在某些可能的混淆?

UPDATE

经过更多的调查(感谢您的评论)我意识到这是一个Outlook可视化问题,无论如何问题仍然不明确。

这是在NotePad ++中打开的电子邮件的正文(我打开了从outlook保存的msg文件),在那里我也显示了换行符(你可以看到#13#10作为CR LF。我用红色和绿色突出显示了2个换行符在outlook中有问题(但你可以看到在NP ++中它们看起来像所有其他的换行符):

Outlook中的电子邮件看起来像这样(请注意,outlook显示该消息有额外的换行符,并且已被删除,但他提供了恢复它们的选项:

选择该选项后,电子邮件就可以了:

我不明白为什么这只发生在一些换行符上。 这有助于您更好地理解问题吗?

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):

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:

After choosing that option the email is ok:

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

最满意答案

您可以尝试使用IdMessage.NoEncode := True以便Body不会被RCF 821编码。

或者更好地使用现代编码IdMessage.ContentType := 'text/html'并用#13#10替换#13#10

编辑:这是一个Outlook Express问题。

看这里和这里 。 解决方法是在每行文本的开头添加2个空字符,以使Outlook不删除中断。


请注意,Microsoft支持还建议使用HTML格式作为Outlook Express的可能解决方法:

方法2. 使用HTML或RTF格式您可以在创建新项目时使用HTML或RTF格式。 或者您可以将现有帖子更改为这些格式。

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.

更多推荐

本文发布于:2023-04-24 21:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/f805a7f84e93e7638bd04c706db43567.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   情况下   电子邮件   在某些   properly

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!