如何通过Web api和jquery在重新注册用户中实现电子邮件确认

时间:2018-07-26 20:09:55

标签: api web

大家好,我正在制作一个asp.net Web API的Web应用程序,我想在注册时应用电子邮件检查功能,我如何实现它,我见过很多网站,但我无法获得确切的结果,请帮助我 我已经从Microsoft网站上阅读了代码,但我不理解该代码以及如何应用它 代码在这里

Go to the Azure SendGrid sign up page and register for a free SendGrid account. Configure SendGrid by adding code similar to the following in App_Start/IdentityConfig.cs:

C#

Copy
public class EmailService : IIdentityMessageService
{
   public async Task SendAsync(IdentityMessage message)
   {
      await configSendGridasync(message);
   }

   // Use NuGet to install SendGrid (Basic C# client lib) 
   private async Task configSendGridasync(IdentityMessage message)
   {
      var myMessage = new SendGridMessage();
      myMessage.AddTo(message.Destination);
      myMessage.From = new System.Net.Mail.MailAddress(
                          "Joe@contoso.com", "Joe S.");
      myMessage.Subject = message.Subject;
      myMessage.Text = message.Body;
      myMessage.Html = message.Body;

      var credentials = new NetworkCredential(
                 ConfigurationManager.AppSettings["mailAccount"],
                 ConfigurationManager.AppSettings["mailPassword"]
                 );

      // Create a Web transport for sending email.
      var transportWeb = new Web(credentials);

      // Send the email.
      if (transportWeb != null)
      {
         await transportWeb.DeliverAsync(myMessage);
      }
      else
      {
         Trace.TraceError("Failed to create Web transport.");
         await Task.FromResult(0);
      }
   }
}
You'll need to add the following includes:

C#

Copy
using SendGrid;
using System.Net;
using System.Configuration;
using System.Diagnostics;

请帮助我,我需要乞and

0 个答案:

没有答案