Sunday 22 January 2012

Simple method to send mails form your asp.net


first include

Using System.Net.Mail;

-------------------------------------------


protected void Button1_Click(object sender, EventArgs e)
    {
        MailMessage mail = new MailMessage();
        mail.To.Add("manjunath4ualways@gmail.com");
        mail.To.Add("manjunath4ualways@gmail.com");
        mail.From = new MailAddress("manjunath.le@smartdrivelabs.com");
        mail.Subject = "Mail from manju";

        string Body = "Hi, this mail is manju ";
        mail.Body = Body;

        mail.IsBodyHtml = true;
     
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
        smtp.Credentials = new System.Net.NetworkCredential
             ("your mail id", "password");
        //Or your Smtp Email ID and Password
        smtp.EnableSsl = false;
        smtp.Send(mail);
    }

thats it........




No comments:

Post a Comment