<span style=”font-weight:bold;”>Send Mail Messages Using System.Net.Mail namespace (new in .net Framework Version 2.0) which provides classes that enable you to easily create and transmit e-mail messages.</span>
Asp.net c#:
// Create a MailMessage object
MailMessage mm = new MailMessage();
// Define the sender and recipient
mm.From = new MailAddress(fromEmailAddress.Text, fromDisplayName.Text);
mm.To.Add(new MailAddress(toEmailAddress.Text, toDisplayName.Text));
// Define the subject and body
mm.Subject = subjectTextBox.Text;
mm.Body = bodyTextBox.Text;
mm.IsBodyHtml = htmlRadioButton.Checked;
// Configure the mail server
SmtpClient sc = new SmtpClient(serverTextBox.Text);
sc.EnableSsl = sslCheckBox.Checked;
if (!String.IsNullOrEmpty(usernameTextBox.Text))
sc.Credentials = new NetworkCredential(usernameTextBox.Text, passwordTextBox.Text);
// Send the message
sc.Send(mm);
//DONE
test
Comment by test — August 21, 2008 @ 5:19 am
hi
Comment by jamchy — November 1, 2008 @ 7:18 am
I wanted to set a web form for exactly what i am doing now so that users of my site may send messages to me from my own server. Before uploading i want to test the web form on my pc using Windows XP, asp.net, sql server, C#. I am not able send the email.
Please help.
Comment by pcg — January 20, 2009 @ 11:15 am
Get the smtp settings(smtpserver, port, uname, pwd) from your hosting provider and use it in your local and live too.
Comment by Admin — May 25, 2011 @ 1:33 pm
may i add please.
I am using SMTPClient “LocalHost” which is giving me troubles. What should i use in place of localhost if any.
Comment by pcg — January 20, 2009 @ 11:33 am
You may need to install smtpserver, have a search on google
Comment by Admin — May 25, 2011 @ 1:32 pm