简体   繁体   中英

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.

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).

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));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM