Friday, 4 May 2012

1 Send Email By gmail using C#

Jaskumarblogspot.com

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;

public partial class userfeedback : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        MailMessage mail = new MailMessage();
        mail.To.Add("Email id ");
        mail.From = new MailAddress("Email Id ");
        mail.Subject = "User Feedback......";


        mail.Body =  "Name:- " + txtname.Text + "     " + "Phone no :- " + txtphone.Text + "     " + "Email id :-  " + txtemail.Text + " " + "Feedback :-  " + txtfeed.Text;
        mail.IsBodyHtml = true;
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
        smtp.Credentials = new System.Net.NetworkCredential
             ("email id ", "password");
        //Or your Smtp Email ID and Password
        smtp.EnableSsl = true;
        smtp.Send(mail);
    }
}

1 comments:

 

Coding Authority Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates