sending e-mail to gmail using web application   Leave a comment

gmail app.




using System;

using System.Net;

using System.Net.Mail;

public partial class _Default : System.Web.UI.Page


MailMessage msgobj;

protected void btnSend_Click(object sender, EventArgs e)


SmtpClient serverobj = new SmtpClient();

serverobj.Credentials = new NetworkCredential(TextBox1.Text, TextBox2.Text);

serverobj.Port = 587;

serverobj.Host = “”;

serverobj.EnableSsl = true;

msgobj = new MailMessage();

msgobj.From = new MailAddress(TextBox1.Text, “email demo”, System.Text.Encoding.UTF8);


msgobj.Priority = MailPriority.High;

msgobj.Subject = TextBox4.Text;

msgobj.Body = TextBox5.Text;

msgobj.Attachments.Add(new Attachment(MapPath(“accept.jpg”)));

msgobj.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;


LabelOutput.Text = “mail sent successfully…!”;






Posted September 20, 2010 by PrashanthChindam in

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your 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: