解决方法
是的,有一种方法.
You can alter web.config like this so
that when you send email it will
instead be created as an .EML file in
c:\LocalDir.
<configuration> <system.net> <mailSettings> <smtp deliveryMethod="SpecifiedPickupDirectory"> <specifiedPickupDirectory pickupDirectoryLocation="c:\LocalDir"/> </smtp> </mailSettings> </system.net> </configuration>@H_404_16@如果您不想/不能更改web.config,也可以使用相同的设置创建
SmtpClient
类的实例.在C#中看起来像这样:var smtpClient = new SmtpClient(); smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; var emailPickupDirectory = HostingEnvironment.MapPath("~/EmailPickup"); if (!Directory.Exists(emailPickupDirectory)) { Directory.CreateDirectory(emailPickupDirectory) } smtpClient.PickupDirectoryLocation = emailPickupDirectory;@H_404_16@