C# – How to save an email instead of sending when using SmtpClient

cemailnetsmtp

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.

Best Answer

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>

Additional Info: