hi
How to send Mail in my asp.net C# application i need perfect code
running condition code
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Mar 16, 2011, 3:33 PM
Soft CornerPosted Mar 15, 2011, 3:11 AM
Also Check Our recommended articles at right hand side,
Sending Mail in ASP.NET using C#
Vijay YadavPosted Mar 15, 2011, 3:09 AM
you can write this code on button click
string from = txtFrom.Text; //Replace this with your whom you want to send the mail
string to = txtTo.Text; //Replace this with the Email Address to whom you want to send the mail
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(from, "Any Name", System.Text.Encoding.UTF8);
mail.Bcc.Add(txtBcc.Text);
mail.CC.Add(txtCc.Text);
mail.Subject = txtSubject.Text;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = txtMessage.Text;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
//Add the Creddentials- use your own email id and password
client.Credentials = new System.Net.NetworkCredential(username, password);// here you have to write your gmail username and password
client.Port = 587; // Gmail works on this port
client.Host = "smtp.gmail.com";
client.EnableSsl = true; //Gmail works on Server Secured Layer
client.Send(mail);