检索电子邮件的AlternateView [英] Retrieving AlternateView's of email

查看:379
本文介绍了检索电子邮件的AlternateView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法从System.Net.Mail.AlternateView中检索AlternateView。



我有一个应用程序通过POP3获取电子邮件。我了解如何为发送创建备用视图,但在查看电子邮件时如何选择备用视图。我已经将收到的电子邮件作为System.Net.MailMessage对象,因此我可以轻松地提取正文,编码,主题行等。我可以看到AlternateViews,也就是说,我可以看到count是2,但是想要来提取除了当我请求body时返回的HTML之外的其他内容。



希望这有一定的意义,并且有人可以对此有所了解。最后,我希望将明文拉出来,而不是HTML,而不是自己解析它。

解决方案

它不可能立即使用System.Net.Mail命名空间中可用的类来解析电子邮件;您需要创建自己的MIME解析器,或者使用第三方库。



Peter Huber SG撰写的这篇伟大的Codeproject文章标题为'具有完全MIME支持(.NET 2.0)的POP3电子邮件客户端将帮助您了解MIME处理可以实现,以及相关的RFC规范文章。

您可以使用Codeproject文章作为编写自己的解析器的开始,或者评估一个库,如 SharpMimeTools ,它是一个用于解析和解码MIME电子邮件的开源库。

http://anmar.eu.org/projects/sharpmimetools/

希望这有助于!


I can't seem to retrieve the AlternateView from System.Net.Mail.AlternateView.

I have an application that is pulling email via POP3. I understand how to create an alternate view for sending, but how does one select the alternate view when looking at the email. I've have the received email as a System.Net.MailMessage object so I can easily pull out the body, encoding, subject line, etc. I can see the AlternateViews, that is, I can see that the count is 2 but want to extract something other than the HTML that is currently returned when I request the body.

Hope this makes some amount of sense and that someone can shed some light on this. In the end, I'm looking to pull the plaintext out, instead of the HTML and would rather not parse it myself.

解决方案

Its not immediately possible to parse an email with the classes available in the System.Net.Mail namespace; you either need to create your own MIME parser, or use a third party library instead.

This great Codeproject article by Peter Huber SG, entitled 'POP3 Email Client with full MIME Support (.NET 2.0)' will give you an understanding of how MIME processing can be implemented, and the related RFC specification articles.

You can use the Codeproject article as a start for writing your own parser, or appraise a library like SharpMimeTools, which is an open source library for parsing and decoding MIME emails.

http://anmar.eu.org/projects/sharpmimetools/

Hope this helps!

这篇关于检索电子邮件的AlternateView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆