问题描述
我运行了一个带有delphi和indy 10的小型电子邮件客户端.我收到的某些邮件具有mime格式或html格式.使用当前代码,我只是将bode.lines复制到memo.lines
I run a small e mail client build with delphi and indy 10. Some mails i receive have the mime format or html format. With the current code I just copy the bode.lines to a memo.lines
MyMailMemo.Lines.AddStrings
(TIdMessage(Msg.Body);
我如何复制哑剧电子邮件的内容?
How do I copy the content of mime emails?
推荐答案
MIME编码的电子邮件不使用 TIdMessage.Body
属性.他们改用 TIdMessage.MessageParts
属性,其中文本MIME部分存储为 TIdText
对象,附件存储为源自 TIdAttachment
的对象.您必须查看 TIdMessage.ContentType
属性,以了解您使用的是HTML电子邮件还是MIME电子邮件.即使那样,HTML电子邮件实际上仍可能是MIME编码的,因为它们通常包括非HTML电子邮件阅读器的替代纯文本MIME部分.您可以遍历 TIdMessage.MessageParts
,查找 ContentType
为HTML的 TIdText
对象,然后复制 TIdText.Body 代码>内容添加到您的TMemo中.
MIME-encoded emails do not use the TIdMessage.Body
property. They use the TIdMessage.MessageParts
property instead, where textual MIME parts are stored as TIdText
objects and attachments are stored as TIdAttachment
-derived objects. You have to look at the TIdMessage.ContentType
property to know whether you are working with an HTML email or a MIME email. Even then, chances are that HTML emails are actually MIME encoded, as they usually include an alternative plain-text MIME part for non-HTML email readers. You can loop through the TIdMessage.MessageParts
looking for a TIdText
object whose ContentType
is HTML, then copy the TIdText.Body
content into your TMemo.
这篇关于如何处理发送给vcl的mime电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!