使用 SmtpClient 时如何保存电子邮件而不是发送? [英] How can I save an email instead of sending when using SmtpClient?

查看:52
本文介绍了使用 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?

如果有人对此有任何经验,我将非常感谢您的帮助或指点.

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:Tempmail"/>
    </smtp>
  </mailSettings>
</system.net>

附加信息:

这篇关于使用 SmtpClient 时如何保存电子邮件而不是发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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