开发者

Send E-mail Notification : MVC project

In my system has the function to sending email notification to warn another department that the contract is开发者_如何学运维 nearly expired.

Has any suggestion to send the email via my mvc project, I try to use System.web.mail but smtp not accept. Do I need to prepare anything to send email.

Thanks you for suggestion.


If you have an SMTP server available, you can use the SMTP client that's part of the .net framework.

You can set up a daemon in the Application_Start method of Global.asax.cs that might check daily for expiring contracts then sends SMTP emails regarding the contracts that are about to expire.

Something like this might be appropriate:

// this is System.Threading.Timer
_timer = new Timer(x =>
                  {
                      var listOfExpiringContracts = GetContractsThatAreAboutToExpire();
                      if (listOfExpiringContracts.Count > 0)
                      {
                          SendEmailToOtherDepartmentRegardingContractsThatAreAboutToExpire(listOfExpiringContracts);
                      }
                  }, null, GetNextTimeToCheckForExpiringContracts().Subtract(DateTime.Now), TimeSpan.FromDays(1));


A contract expiring is going to be a function of time, not of an HTTP request.

This should be handled outside the MVC application (although it should almost certainly reuse the classes that the Model is built on).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜