从 MHT 文档中提取内容

发布于 2024-07-30 19:27:00 字数 864 浏览 12 评论 0原文

是否有人知道任何用于处理 MHT 文件的库(多部分 MIME 文件)在.NET 中? 我需要以编程方式从包含 Flash 网站的现有 MHT 文件中提取内容。 我无法找到任何此类库。

另外,如果 .NET 中有我不知道的本机方式,请随时告诉我。

编辑:我知道MailMessage 类通过 AlternateViews 属性AlternateView 类表示多部分 MIME 消息。 我相信可以利用这些知识来使用 .NET 框架的原生代码构建一些东西。 我只是一直没能找到合适的组合来让它发挥作用,所以我开始失去信心。 有谁知道是否可以通过 AlternateView 和其他相关类提取 MHT 文件的内容? 例如,如果可以从 Stream 创建 MailMessage 类的实例,那就太好了。

Is anybody aware of any libraries for working with MHT files (Multi-Part MIME files) in .NET? I need to programmatically extract the contents from an existing MHT file containing a Flash website. I haven't been able to locate any such libraries.

Also, if there's a native way in .NET that I'm not aware of, please feel free to let me know.

EDIT: I know that the MailMessage class supports multi-part MIME messages through the AlternateViews property. The AlternateView class represents the alternative views in a multi-part MIME message. I'd like to believe that it's possible to use this knowledge to build something using code native to the .NET framework. I just haven't been able to find out the right combination to make it work, so I'm starting to loose faith. Does anybody out there know if it's possible to extract the contents of a MHT file through the AlternateView and other related classes? For example, it would be nice if it were possible to create an instance of the MailMessage class from a Stream.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我纯我任性 2024-08-06 19:27:00

您可能对我在 github 上的 MIME 解析项目(用 C# 编写)

https://github.com/smithimage/ 感兴趣MIMER/

还有一个 Nuget 包:

https://nuget.org/packages/MIMER/

You might be interessed in my MIME parsing project at github (written in C#)

https://github.com/smithimage/MIMER/

Also has a Nuget package:

https://nuget.org/packages/MIMER/

∞梦里开花 2024-08-06 19:27:00

http://www.lumisoft.ee/lswww/ ENG/Products/Mail_Server/mail_index_eng.aspx?type=info

这是开源电子邮件服务器,具有良好的 Mime 解析器。

http://www.lumisoft.ee/lswww/ENG/Products/Mail_Server/mail_index_eng.aspx?type=info

This is open source email server which has good Mime Parser.

盗梦空间 2024-08-06 19:27:00

David Benko 这里他的 github 项目做得很好。 我最近遇到了一个问题,我有一个 mhtml 需要转换为 HTML 文件。 为此,我使用 HTMLAgility pack dll 从 mhtml 文件中提取内容,并将这些内容提供给 David 提供的库:

string filePath = @"D:\Temp\myfile.mhtml";
var doc = new HtmlDocument();
doc.Load(filePath);
string mhtml = doc.DocumentNode.OuterHtml;
MHTMLParser parser = new MHTMLParser(mhtml);
string htmlContent = parser.getHTMLText();
System.IO.File.WriteAllText(@"D:\Temp\file.html", htmlContent);

如果有人可以验证这种方法,我将非常感激。
干杯
瓦卡尔

David benko did a great job here his github project. I recently faced a this issue where I had an mhtml that needed to be converted to HTML file. for that I used HTMLAgility pack dll to extract content from the mhtml file and feed in this content to David's provided library:

string filePath = @"D:\Temp\myfile.mhtml";
var doc = new HtmlDocument();
doc.Load(filePath);
string mhtml = doc.DocumentNode.OuterHtml;
MHTMLParser parser = new MHTMLParser(mhtml);
string htmlContent = parser.getHTMLText();
System.IO.File.WriteAllText(@"D:\Temp\file.html", htmlContent);

I would really appreciate if someone could verify this approach.
Cheers
Vaqar

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文