public async Task SendAsync(IdentityMessage message)
        {
            // Configuration for sending mail via Google account
            // "Allow less secure apps" must be enable (Google Account)
            MailMessage mail = new MailMessage();

            AppSettings appSettings;

            using (var db = new ApplicationDbContext())
            {
                appSettings = db.AppSettings.FirstOrDefault();
            }

            mail.From = new MailAddress(appSettings.EmailAddress);
            mail.To.Add(new MailAddress(message.Destination));

            mail.Subject    = message.Subject;
            mail.Body       = message.Body;
            mail.IsBodyHtml = true;

            using (var gmailClient = new GmailService(appSettings.EmailUsername, appSettings.EmailPassword))
            {
                await gmailClient.SendMailAsync(mail);

                mail.Dispose();
            }

            // return Task.FromResult(0);
        }
Пример #2
0
        public async Task SendAsync(IdentityMessage message)
        {
            // Plug in your email service here to send an email.
            MailMessage email = new MailMessage(
                new MailAddress("*****@*****.**", "do not reply"),
                new MailAddress(message.Destination)
                );

            email.Subject    = message.Subject;
            email.Body       = message.Body;
            email.IsBodyHtml = true;
            using (var mailClient = new GmailService())
            {
                await mailClient.SendMailAsync(email);
            }
        }
Пример #3
0
        public async Task SendAsync(IdentityMessage message)
        {
            // Plug in your email service here to send an email.
            //return Task.FromResult(0);
            MailMessage email = new MailMessage(
                new MailAddress("*****@*****.**", "(do not reply)"),
                new MailAddress(message.Destination));

            email.Subject    = message.Subject;
            email.Body       = message.Body;
            email.IsBodyHtml = true;

            using (var mailClient = new GmailService())
            {
                //In order to use the original from email address, uncomment this line:
                //email.From = new MailAddress(mailClient.UserName,"(do not reply)";
                await mailClient.SendMailAsync(email);
            }
        }