public Send ( string from, string recipients, string subject, string body ) : void | ||
from | string | |
recipients | string | |
subject | string | |
body | string | |
return | void |
public void Send(string from, string recipients, string subject, string body)
{
if (_disposed)
{
throw new ObjectDisposedException(GetType().FullName);
}
//validation happends in MailMessage constructor
MailMessage mailMessage = new MailMessage(from, recipients, subject, body);
Send(mailMessage);
}
SmtpClient::Send ( |
public ActionResult HandleFormSubmit(ContactFormViewModel model) { // send email from the post inserted if (!ModelState.IsValid) return CurrentUmbracoPage(); MailMessage message = new MailMessage(); message.To.Add("*****@*****.**"); message.Subject = "New contact detals"; message.From = new System.Net.Mail.MailAddress(model.ContactEmail, model.ContactName); message.Body = model.ContactMessage; SmtpClient client = new SmtpClient(); try { client.Send(message); } catch (Exception ex) { Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString()); } //var thankYouPageUrl = library.NiceUrl(model.ThankYouPageId); //var thankYouPageUrl2 = thankYouPageUrl + "?id="; //var thankYouPageUrl3 = thankYouPageUrl2 + model.ReturnPageId.ToString(); var thankYouPageUrl = library.NiceUrl(model.ThankYouPageId) + "?id=" + model.ReturnPageId.ToString(); Response.Redirect(thankYouPageUrl); return CurrentUmbracoPage(); }