Seach

how to send email in c# asp.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;

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

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SmtpClient sc = new SmtpClient("smtp.gmail.com", 587)
        {
            Credentials =new NetworkCredential("your mailid","your password"),EnableSsl=true       

        };
        sc.Send("from mail", "to mail", "subject", "body");
    }
}

No comments: