public async System.Threading.Tasks.Task <ActionResult> SendMailResult(MailModel mailModel, int?id, HttpPostedFileBase uploadFile) { var user = Helpers.GetCurrentUser(this.User); //var id=Url.RequestContext.RouteData.Values["id"]; if (id == null || user.Role == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ThesisForm thesisForm = db.Thesises.Find(id); if (thesisForm == null) { return(HttpNotFound()); } //This what a mail will contain var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>"; var message = new MailMessage(); message.To.Add(new MailAddress(mailModel.Email)); //replace with valid value message.Subject = mailModel.Subject; message.From = (new MailAddress(user.Email)); //sending the Professor's mail if (user.Role == "Professor") { message.Body = string.Format(body, "AegeanThesis", user.Email, "User " + user.Name + " is wants approve for this thesis <a href =\"http://localhost:61006/ThesisForms/Details/" + id + ">localhost:61006/ThesisForms/Details/</a>" + "\n" + mailModel.Notes); } else //ortherwise the user is Student so we send his mail { message.Body = string.Format(body, "AegeanThesis", user.Email, mailModel.Notes); } message.IsBodyHtml = true; if (uploadFile != null) { string fileName = Path.GetFileName(uploadFile.FileName); message.Attachments.Add(new Attachment(uploadFile.InputStream, fileName)); } //using the Gmail service used before for user validation using (var smtp = new GmailEmailService()) { await smtp.SendMailAsync(message); } //Showing each page respectively if (user.Role == "Professor") { return(View("BoardSent")); } else { return(View("MailProfessor")); } }
public async Task SendAsync(IdentityMessage message) { MailMessage email = new MailMessage(new MailAddress("*****@*****.**", "noreply@TeeShirtEmporium"), new MailAddress(message.Destination)); email.Subject = message.Subject; email.Body = message.Body; email.IsBodyHtml = true; GmailEmailService mailClient = new GmailEmailService(); await mailClient.SendMailAsync(email); }
public async Task SendAsync(IdentityMessage message) { MailMessage email = new MailMessage(new MailAddress("*****@*****.**", "TRAEKTORIA"), new MailAddress(message.Destination)); email.Subject = message.Subject; email.Body = message.Body; email.IsBodyHtml = true; using (var mailClient = new GmailEmailService()) { await mailClient.SendMailAsync(email); } }
public async Task SendAsync(IdentityMessage message) { MailMessage email = new MailMessage(new MailAddress("*****@*****.**", "Chợ Xe"), new MailAddress(message.Destination)); email.Subject = message.Subject; email.Body = message.Body; email.IsBodyHtml = true; using (var mailClient = new GmailEmailService()) { //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); } }
public async Task NotifyAdminByEmail(string subject, string body) { using (var mailClient = new GmailEmailService()) { MailMessage email = new MailMessage(new MailAddress("*****@*****.**", "(do not reply)"), new MailAddress(mailClient.UserName)); email.Subject = subject; email.Body = body; email.IsBodyHtml = true; //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); } }
// Use NuGet to install SendGrid (Basic C# client lib) private async Task configSendGridasync(IdentityMessage message) { 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 GmailEmailService()) { //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); } }
public async Task SendAsync(IdentityMessage message) { MailMessage email = new MailMessage(new MailAddress("*****@*****.**", "(do not reply)"), new MailAddress(message.Destination)) { Subject = message.Subject, Body = message.Body, IsBodyHtml = true }; using (var mailClient = new GmailEmailService()) { //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); } }
public Task Execute(string strSubject, string strMessage, string strEmailTo) { MailMessage email = new MailMessage(new MailAddress(Options.From, "(do not reply)"), new MailAddress(strEmailTo)); email.Subject = strSubject; email.Body = strMessage; email.IsBodyHtml = true; var mailClient = new GmailEmailService(Options.Server, Options.Port, Options.SSL, Options.Username, Options.Password); { //In order to use the original from email address, uncomment this line: //email.From = new MailAddress(mailClient.UserName, "(do not reply)"); return(mailClient.SendMailAsync(email)); } /* * var client = new SendGridClient(apiKey); * var msg = new SendGridMessage() * { * From = new EmailAddress("*****@*****.**", Options.SendGridUser), * Subject = subject, * PlainTextContent = message, * HtmlContent = message * }; * msg.AddTo(new EmailAddress(email)); * * // Disable click tracking. * // See https://sendgrid.com/docs/User_Guide/Settings/tracking.html * msg.SetClickTracking(false, false); * * return client.SendEmailAsync(msg); */ }
// GET: ThesisForms/Interested public async System.Threading.Tasks.Task <ActionResult> Interested(int?id) { var user = Helpers.GetCurrentUser(this.User); ThesisForm thesisForm = db.Thesises.Find(id); if (user.Role.Equals("Professor")) { return(RedirectToAction("InterestedMessage")); } else if (user.Role.Equals("Student")) { //This what a mail will contain var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>"; var message = new MailMessage(); message.To.Add(new MailAddress(thesisForm.Supervisor + "@aegean.gr")); //replace with valid value message.Subject = "Your email subject"; message.From = (new MailAddress("*****@*****.**")); message.Body = string.Format(body, "AegeanThesis", "*****@*****.**", "User " + user.Email + " is interested about thesis " + thesisForm.Title); message.IsBodyHtml = true; //using the Gmail service used before for user validation using (var smtp = new GmailEmailService()) { await smtp.SendMailAsync(message); } return(RedirectToAction("InterestedSent")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (thesisForm == null) { return(HttpNotFound()); } return(View()); }
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 GmailEmailService()) { //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); } //return Task.FromResult(0); }