将邮件内容导出到Asp.net中的word文档,c# [英] Export Mail content to word document in Asp.net,c#

查看:89
本文介绍了将邮件内容导出到Asp.net中的word文档,c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



任务:如何在asp.net,C#中将单个邮件内容转换为word文档。我的客户使用Lotus Notes邮件服务器发送和接收邮件。



我必须尽快完成这项任务。



我欢迎您提出可能对我有帮助的宝贵建议或想法。

非常感谢您提前。

解决方案

< blockquote>首先,您需要解析邮件消息的内容。为此,您需要编写.NET FCL中不可用的代码,或者查找某些第三方库。我推荐开源OpenPOP.NET: http://hpop.sourceforge.net [ ^ ]。



这个库编写得不是很好,但它完全遵循邮件结构,标题和MIME类型的所有标准。所有这些东西的复杂性是由于各种不同的内容类型,处置以及多部分内容(每个部分的内容类型和内容配置不同)。



要创建Word文档,您可以使用Office Interop程序集,或者更好的Microsoft Open SDK。实际上,Microsoft警告不要在服务器环境中使用Office Interop:

http://support.microsoft.com/default.aspx?scid=kb;EN-US ; q257757 #kb2 [ ^ ],

http://support.microsoft.com / kb / 257757 / zh-CN [ ^ ]。



在Open XML SDK上,请参阅:



http://www.microsoft.com/en-us/download/details.aspx?id=30425 [ ^ ]。



这样,您可以支持新的基于XML的Office格式(例如.DOCX,.XLSX),ECMA-376标准:

http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats [ ^ ],

http://en.wikipedia.org/wiki/Office_Open_XML [ ^ ]。



这样,您可以在没有安装Office的情况下工作。此外,第三方软件支持这些文档。请查看我过去的答案:

将Office文档转换为PDF而不互操作 [ ^ ],
需要一个相当独特的WPF文本编辑器控件 [ ^ ],

您好如何使用c#.net 在Windows应用程序中显示word文件[ ^ ],

阅读没有使用Interop.word dll的word文件...不想在IIS中安装单词。 [ ^ ]。



这是另一种选择: http://npoi.codeplex.com/ [ ^ ]。



参见:


Dear All,

Task: How to convert single mail content to word document in asp.net, C#. My client using "Lotus Notes" mail server for send and receive mail.

I have to complete this task ASAP.

I welcome for your valuable suggestions or ideas that might be helpful for me.
Thank you very much in advance.

解决方案

First, you need to parse the content of mail message. For this purpose, you need to write code not available in .NET FCL, or find some 3rd-party library. I would recommend open-source OpenPOP.NET: http://hpop.sourceforge.net[^].

This library is not very well written, but it thoroughly follows all those standard for mail structure, headers and MIME types. The complexity of all of this stuff is due to the big variety of different content types, dispositions and also due to multi-part content (with different content type and content disposition for every part.

To create Word documents, you can use either use Office Interop assemblies, or, better, Microsoft Open SDK. Actually, Microsoft warns against using Office Interop in server environment:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

On Open XML SDK, please see:

http://www.microsoft.com/en-us/download/details.aspx?id=30425[^].

This way, you can support new XML-based Office formats (such as .DOCX, .XLSX), ECMA-376 standard:
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML[^].

This way, you can work without Office installed. Also, the documents are supported by 3rd-party software. Please see my past answers:
Convert Office-Documents to PDF without interop[^],
Need a rather unique WPF text editor control[^],
Hi how can i display word file in windows application using c#.net[^],
Read a word file without using Interop.word dll...Do not want to install word in IIS..[^].

This is another option: http://npoi.codeplex.com/[^].

See also:


这篇关于将邮件内容导出到Asp.net中的word文档,c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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