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


gmail app.

Design:

——————–

Code:

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 = “smtp.gmail.com”;

serverobj.EnableSsl = true;

msgobj = new MailMessage();

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

msgobj.To.Add(TextBox3.Text);

msgobj.Priority = MailPriority.High;

msgobj.Subject = TextBox4.Text;

msgobj.Body = TextBox5.Text;

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

msgobj.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

serverobj.Send(msgobj);

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

}

}

————–

Output:

Advertisements

Posted September 20, 2010 by PrashanthChindam in asp.net

Leave a Reply

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

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: