Wednesday 27 June 2012

how to send mail in webmatrix

Sending E-mail

Sending e-mail from an ASP.NET web site was already quite easy, but by adding some Helper methods things are now easier than ever:
var customerName = Request["customerName"];     
var customerRequest = Request["customerRequest"]; 

// Initialize Mail helper
Mail.SmtpServer = "your SMTP host";
Mail.SmtpPort = 587;
Mail.EnableSsl = true;
Mail.UserName = "your user name here";
Mail.From = "your email address here";
Mail.Password = "your accound password";

// Send email
Mail.Send(to: "target email address here", subject: "Help request from - " + 
       customerName, body: customerRequest
);  

No comments:

Post a Comment