C# – Delaying the sending of emails in C#

asp.netcemailnet

We are writing a feature to send a reminder email to customers in x number of days and just wondered if it was possible to delay the sending of the emails similar to how you can in Outlook (New Mail > Options button > Do not deliver before) in C#.

Does anyone know of a way of doing this?

Best Answer

If you want to submit the email to an SMTP server to hold for a number of days, the server would have to support this feature. I would recommend against doing it that way, however. If you had a problem with missing emails it could be hard to track down.

Here's what I would do:

  1. Schedule the emails in your system by making a table entry.
  2. Include a "SendDate" column in the table where you can set a date in the future
  3. Write a Windows service that wakes up once every 15 minutes (for example) and sends the emails in that table where SendDate < currentDate