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

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

问题描述

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

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

希望这在一定程度上有意义,并且有人可以对此有所了解.最后,我希望提取纯文本,而不是 HTML,并且宁愿自己不解析它.

解决方案

使用 System.Net.Mail 命名空间中可用的类无法立即解析电子邮件;您要么需要创建自己的 MIME 解析器,要么改用第三方库.

Peter Huber SG 撰写的这篇很棒的 Codeproject 文章,标题为 'POP3 Email Client with full MIME支持 (.NET 2.0)' 将使您了解如何实现 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!

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

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