I am using SmtpClient
and MailMessage
to send emails from ASP.Net
code.
I want to be able to delay the delivery of emails based on business logic.
I will be able to generate a DateTime
object about when the email should actually be delivered.
I am aware that I can create a Windows Service to schedule email delivery using Sql Server
database as an email storage. But I do not want to deploy an extra service on the hosting server.
I am also aware that I can create a SQL Server
job to achieve this, but I would not like to, until and unless, this cannot be achieved using pure ASP.NET
A point to note is that, my code checks whether MSMQ
is enabled on the server. If it is, MessageQueue
class is used for email delivery. So any pointers on achieving this using queues will be helpful.
By the way, the solution should work in both cases (i.e. with SmtpClient
as well as MessageQueue
.
I have already reviewed this and this questions and its accepted answers. I do not want to use 3rd party products until and unless this cannot be achieved using pure ASP.NET
P.S. .Net Framework version : 3.5, IIS 7 and Sql Server 2008 should be the environment.