Asp.net mvc 4 使用Revalee.client在后台发送电子邮件

Asp.net mvc 4 使用Revalee.client在后台发送电子邮件,asp.net-mvc-4,Asp.net Mvc 4,我应该在哪里调用revalee方法在后台发送邮件?我试图实现的是在到期日即将到来时向客户发送电子邮件。我已通过以下链接: 我的行动方法如下: public ActionResult SendExpirationMessage(int VehicleID) { // Validate the incoming request to ensure that this web app requested this callback if (!Revale

我应该在哪里调用revalee方法在后台发送邮件?我试图实现的是在到期日即将到来时向客户发送电子邮件。我已通过以下链接:

我的行动方法如下:

    public ActionResult SendExpirationMessage(int VehicleID)
    {
        // Validate the incoming request to ensure that this web app requested this callback
        if (!RevaleeRegistrar.ValidateCallback(this.Request))
        {
            // Return a '401 Unauthorized' response to the Revalee service if the callback doesn't validate
            return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
        }

        ApplicationDbContext db = new ApplicationDbContext();
        var user = db.UserVehicleViewModels.Find(VehicleID);
        var span = user.TaxDate.AddYears(1).Subtract(DateTime.Now);
        int days = span.Days;
        if (days >= 7)
        {

            System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(
            new System.Net.Mail.MailAddress("abc@abc.com", "Web Registration"),
            new System.Net.Mail.MailAddress(user.Email));
            m.Subject = "Tax Notification";
            m.Body = string.Format("Dear {0} <BR/>This is an email to notify you about the due tax date of your vehicle, please pay tax on time. Thank you\" title=\"User Email Confirm\"></a>",
                user.UserName);
            m.IsBodyHtml = true;
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
            smtp.Credentials = new System.Net.NetworkCredential("abc@abc.com", "password");
            smtp.EnableSsl = true;
            smtp.Send(m);
        }

您是否安装并配置了Revalee服务器(它是一个独立于Revalee客户端的Windows服务)?Revalee客户端需要服务器组件,客户端web应用程序(安装了Revalee.client包的地方)将从其
web.config
引用Revalee服务器。有关更多信息,请访问该网站。您是否安装并配置了Revalee服务器(它是一个独立于Revalee客户端的Windows服务)?Revalee客户端需要服务器组件,客户端web应用程序(安装了Revalee.client包的地方)将从其
web.config
引用Revalee服务器。有关更多信息,请访问网站。
    private void ScheduleExpirationMessage(int VehicleID)
    {
        // The server address where the Revalee service is installed
        string revaleeServiceHost = "192.168.1.4";

        // The callback will occur 27 days from now
        DateTimeOffset callbackTime = DateTimeOffset.Now.AddMinutes(1.0);

        // The url that will be called back, including userId
        Uri callbackUrl = new Uri(
            string.Format("http://localhost/UserVehicle/SendExpirationMessage/{0}", VehicleID));

        // Register the callback request with the Revalee service
        RevaleeRegistrar.ScheduleCallback(revaleeServiceHost, callbackTime, callbackUrl);
    }