使用SmtpClient时如何保存电子邮件而不是发送? [英] How can I save an email instead of sending when using SmtpClient?
问题描述
我正在使用SmtpClient发送带有附件的电子邮件。
但是对于某个批次,我们需要以某种方式保存MailMessage而不是发送它们。
我们正在想/希望将消息手动上传到用户草稿文件夹。
I am using SmtpClient to send an email with an attachment. However for a certain batch we need to somehow save the MailMessage instead of sending them. We are then thinking/hoping to manually upload the messages to the users drafts folder.
是否可以保存这些附件的消息(不可能,我会想的)或者将消息上传到用户帐户中的文件夹?
Is it possible to save these messages with the attachment intact (impossible, I would have thought). Or alternatively upload the messages to a folder in the users account?
如果有任何人有这方面的经验,我会非常感谢一些帮助或指针。 / p>
If anyone has any experience of this, I'd much appreciate a bit of help or a pointer.
推荐答案
在ASP.NET中测试时,我们将电子邮件保存到一个文件夹,然后通过电子邮件服务器发送。也许您可以更改您的批次中的 web.config
设置?
When testing in ASP.NET we save our emails to a folder rather then send them through an email server. Maybe you could change yourweb.config
settings like this for your batch?
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\Temp\mail\"/>
</smtp>
</mailSettings>
</system.net>
附加信息
- MSDN: <specifiedPickupDirectory> Element (Network Settings)
- Configuring SmtpClient to drop emails in a folder on disk
这篇关于使用SmtpClient时如何保存电子邮件而不是发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!