Chris
Chris

Reputation: 11

sending to an email with contact form asp.net

How would I go about sending an email to a specified email address with a contact form in asp.net? The website is hosted though a hosting company. thanks

Upvotes: 0

Views: 1088

Answers (1)

Scott
Scott

Reputation: 13931

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("your.mail.server");

mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail";

SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");

SmtpServer.Send(mail);

Upvotes: 1

Related Questions