我的问题是,我需要使用 C# 将文件附加到默认邮件客户端并将其显示给用户,就像使用 mailto:
一样。
我读了这篇关于该主题的帖子,但有几个问题:
- 我不想使用
mailto
因为附件不受官方支持。
- 当使用 System.Net.Mail 和 SMTP 类(接受的答案中提供的代码)时,我不确定如何弹出消息供用户处理,而不仅仅是邮寄它。不确定这是否可能。
- 另外,当使用上面的解决方案(#2)时,我不确定如何获取用户的电子邮件服务器。
- 在下面提供的答案中,使用 MAPI32.DLL 的自定义包装器提供了代码项目解决方案。这里的问题是,文章作者为此解决方案指定的许可协议与我的项目要求相冲突。
- 由于时间限制,我无法编写自己的 MAPI 包装器
那么,对于这个问题还有其他简单的解决方案吗?是否有另一种简单的方法来弹出默认邮件客户端,其中附件预先填充有 .NET?也许是另一种 MAPI 包装器,但许可证非常宽松?
My issue is that I need to attach files with C# to the default mail client and show it to the user, much like using mailto:
.
I read this post on the subject, but there are several issues:
- I do not want to use
mailto
because attachments are not officially supported.
- When using System.Net.Mail and the SMTP class (code supplied in the accepted answer), I am not sure how to pop up the message for the user to handle instead of just mailing it. Not sure if this is even possible.
- Also when using the solution above (#2) I'm not sure how to get the user's email server.
- In an answer supplied further down, a Code Project solution is presented using a custom wrapper for MAPI32.DLL. The issue here is that the license agreement specified by the writer of the article for this solution conflicts with the requirements that I am under for my project.
- Due to time restrictions I cannot write my own MAPI wrapper
So, are there any other simple solutions to this problem? Is there another simple way to pop up the default mail client with the attachments pre-populated with .NET? Maybe another MAPI wrapper, but one with a VERY lenient license?
发布评论
评论(2)
.NET mapi 包装器确实是最好的解决方案 - 谷歌搜索“mapi .net 包装器”返回了许多结果,我确信其中一个将有合适的许可证:
A .NET mapi wrapper is indeed the best solution - there are many results returned for a google of "mapi .net wrapper", I am sure one of these will have a suitable license:
如果您对未嵌入的附件感到满意,这里有大量代码可以完成这项工作。对于其他可能会来寻找的人来说,这比我确信肯定已经找到替代方案的OP更重要。如果缺少某些内容请添加评论,我将添加必要的内容。享受!
If you are happy with attachments that are not embedded here's a whole lot of code that will do the job. This is more for others who may come looking than OP who I am certain must have already found an alternative. Add a comment if something is missing and I'll add the necessary stuff. Enjoy!