Send Email using Asp.net

Hello Friends please read below code and if you face any problem then inform me.

using System.Net.Mail;
using System.Net;

SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

smtpClient.Host = “smtp.live.com”;
smtpClient.Port = 25;    // Optional port number
message.From = fromAddress; // From Email Address
message.To.Add(“amit@kunjservices.com”); //Send To Address
message.Subject = “Feedback”;     // Email Subject
message.CC.Add(“dhaval@kunjservices.com”); // CC Address
message.Bcc.Add(new MailAddress(“asif@kunjservices.com”)); //BCC Address
message.IsBodyHtml = false; // Body HTML allow false or not
message.Body = txtMessage.Text; //Message Body
smtpClient.Credentials = new NetworkCredential(“huddani_asif@hotmail.com”, “”); // Give Username and Password
smtpClient.EnableSsl = true;    // SSL Secure true or false
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; // Delivery Method network allow or not.
smtpClient.Send(message); // Send message
lblStatus.Text = “Email successfully sent.”;  //Label

Advertisements

About Asif
Hello Friends… I have done my Bachelor of Engineering in Information Technology from Gujarat University. I have 1.7 years experience of web and windows based application development.. My basic idea to start a blog is to store all important link which help me in my application and access to every where. Also this information is help others who want to makes their application powerful. I am interested in .net framework (1.0,2.0,3.0,3.5 and more). This blog contain also many information related to SQL, Custom Controls in C#.net Please share your ideas and any query if you have...

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: