public void Send(TaskReminder reminder) { var message = _translator.Translate(reminder); using (var client = new SmtpClient()) { //_smtpDetails = new SmtpDetails() //{ // Server = "smtp.friends.com", // Port = 587, // UserName = "******", // Password = "******" //}; client.Connect(_smtpDetails.Server, _smtpDetails.Port, false); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2"); // Note: only needed if the SMTP server requires authentication client.Authenticate(_smtpDetails.UserName, _smtpDetails.Password); client.Send(message); client.Disconnect(true); } }
public Mail Translate(TaskReminder taskReminder) { var mail = Mail.GetInstance(); mail.AddTo(taskReminder.ReminderTo); mail.AddCc(taskReminder.CopyReminderTo); mail.Subject = string.Format("Task Reminder! Task {0} is due on {1}", taskReminder.TaskName, taskReminder.DueDate); return mail; }
public void Send(TaskReminder reminder) { var mail = _translator.Translate(reminder); var credentials = new NetworkCredential( ConfigurationManager.AppSettings["sendGridUserName"], ConfigurationManager.AppSettings["sendGridPassword"] ); var api = Web.GetInstance(credentials); api.DeliverAsync(mail).Wait(); }
public MimeMessage Translate(TaskReminder taskReminder) { var message = new MimeMessage(); message.From.Add(new MailboxAddress("Tasks Reminder", "*****@*****.**")); message.To.Add(new MailboxAddress(taskReminder.ReminderTo, taskReminder.ReminderTo)); message.Cc.Add(new MailboxAddress(taskReminder.CopyReminderTo, taskReminder.CopyReminderTo)); message.Subject = string.Format("Task Reminder! Task {0} is due on {1}", taskReminder.TaskName, taskReminder.DueDate); message.Body = new TextPart("plain") { Text = string.Format("Task {0} is due on {1}", taskReminder.TaskName, taskReminder.DueDate) }; return message; }