本文介绍了如何将MailMessage对象保存为* .eml或* .msg文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将MailMessage对象保存到磁盘? MailMessage对象不显示任何Save()方法。

How do I save MailMessage object to the disk? The MailMessage object does not expose any Save() methods.

如果以任何格式保存* .eml或* .msg,我没有问题。任何想法如何做到这一点?

I dont have a problem if it saves in any format, *.eml or *.msg. Any idea how to do this?

推荐答案

为了简单起见,我将引用:

For simplicity, I'll just quote an explanation from a Connect item:

SmtpClient client = new SmtpClient("mysmtphost");
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = @"C:\somedirectory";
client.Send(message);

您还可以在
应用程序配置文件中设置,如

You can also set this up in your application configuration file like this:



 <configuration>
     <system.net>
         <mailSettings>
             <smtp deliveryMethod="SpecifiedPickupDirectory">
                 <specifiedPickupDirectory pickupDirectoryLocation="C:\somedirectory" />
             </smtp>
         </mailSettings>
     </system.net>
 </configuration>



您应该能够使用空的构造函数而不是列出的构造函数,因为它不会发送它。

You should be able to use the empty constructor instead of the one listed, as it won't be sending it anyway.

这篇关于如何将MailMessage对象保存为* .eml或* .msg文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 08:46