Пример #1
0
        public async Task SendEmail(string emailAddress, string subject, string body)
        {
            SendGrid.SendGridMessage message = new SendGrid.SendGridMessage();
            message.From = new System.Net.Mail.MailAddress("*****@*****.**");
            message.To   = new System.Net.Mail.MailAddress[]
            {
                new System.Net.Mail.MailAddress(emailAddress)
            };
            message.Subject = subject;
            message.Html    = body;
            message.DisableClickTracking();
            message.DisableOpenTracking();

            string userName    = System.Web.Configuration.WebConfigurationManager.AppSettings["SendGridUserName"];
            string password    = System.Web.Configuration.WebConfigurationManager.AppSettings["SendGridPassword"];
            var    credentials = new NetworkCredential(userName, password);

            await new SendGrid.Web(credentials).DeliverAsync(message);
        }