public ActionResult Contact(ContactUsViewModel model) { if (!ModelState.IsValid) { ViewBag.SubmitEmailSent = false; return(View("AboutUs")); } // Send email to Scrum Lords for approval var email = new MailMessage(); email.To.Add(_gmailer.GetEmailAddress()); email.From = new MailAddress(model.Email); email.Subject = $"Support inquiry received from {model.Name}."; email.Body = $"Received following inquiry from {model.Name}, email address {model.Email}: " + model.Message; email.IsBodyHtml = true; // Send email and return to view if successful if (_gmailer.Send(email)) { ViewBag.SubmitEmailSent = true; return(View("AboutUs", model)); } // Email could not be sent, display error ViewBag.SubmitEmailSent = false; ViewData.ModelState.AddModelError("EmailError", "Unfortunately, your email could not be sent."); return(View("AboutUs", model)); }
public void SendAccountEmail(string emailAddress, string subject, string body) { var accountEmail = _gMailService.Send(new MailMessage(_gMailService.GetEmailAddress(), emailAddress) { Subject = subject, Body = body }); }
public ActionResult ClaimVenue(ClaimVenueFormViewModel model) { if (!ModelState.IsValid) { ViewBag.SubmitEmailSent = false; return(View(model)); } // Send email to Scrum Lords for approval var email = new MailMessage(); email.To.Add(_gMailer.GetEmailAddress()); email.From = new MailAddress(model.Email); email.Subject = $"Received request to claim venue {model.VenueName}."; email.Body = $"Received below request to claim venue {model.VenueName}:<br />" + $"Name: {model.FirstName} {model.LastName}<br />" + $"Email: {model.Email}<br />" + $"Phone: {model.PhoneNumber}<br />" + $"Company name (if applicable): {model.CompanyName}<br />" + "Proof of ownership document is attached."; email.IsBodyHtml = true; var attachment = new Attachment(model.Document.InputStream, model.Document.FileName); email.Attachments.Add(attachment); // Send email and return to view if successful if (_gMailer.Send(email)) { ViewBag.SubmitEmailSent = true; return(View(model)); } // Email could not be sent, display error ViewBag.SubmitEmailSent = false; ViewData.ModelState.AddModelError("EmailError", "Unfortunately, your email could not be sent."); return(View(model)); }
public void SendMessage(Game game, int playerId, string body, string subject) { //Initializing Message Details string sendingToEmail = ""; string messageContent = ""; //Either sending the message to the Creator of the game or the Players in the game if (game.ContactId == playerId) { sendingToEmail = _contactService.GetContactById((int)game.ContactId).Email; messageContent = body; } else { if (_contactService.GetContactById(playerId) != null) { //emailing to the players on the game list sendingToEmail = _contactService.GetContactById(playerId).Email; } else { //email to the venue owner sendingToEmail = _venueOwnerService.GetVenueOwnerById(playerId).Email; } messageContent = body; } MailMessage mailMessage = new MailMessage(_gMailer.GetEmailAddress(), sendingToEmail) { Body = messageContent, Subject = subject }; //Send the Message _gMailer.Send(mailMessage); }
/* * PBI 148 Austin Bergman */ public void SendInvite(Game game, int friendContactId, string body, string subject) { //find the current logged-on user string email = User.Identity.GetUserName(); Contact currContactUser = _contactService.GetContactByEmail(email); string sendToEmail = ""; string messageContent = ""; messageContent = body; // sending email to the friend sendToEmail = _contactService.GetContactById(friendContactId).Email; MailMessage mailMessage = new MailMessage(_gMailer.GetEmailAddress(), sendToEmail) { Body = messageContent, Subject = subject }; _gMailer.Send(mailMessage); }