Reputation: 11
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
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