SENDING MAIL FROM ASP.NET

Use this Header files
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.Data;
using System.Data.SqlClient;

protected void LoginClick(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("mattengineeringequipments@gmail.com");
msg.To.Add(txtEmail.Text);
msg.Subject = "REGISTRATION";
msg.Body = "Registered Successfully";
msg.IsBodyHtml = true;
SmtpClient smt = new SmtpClient();
smt.Host = "smtp.gmail.com";
System.Net.NetworkCredential ntwd = new NetworkCredential();
ntwd.UserName = "mattengineeringequipments@gmail.com"; //Your Email ID
ntwd.Password = "engg_1234"; // Your Password
smt.UseDefaultCredentials = true;
smt.Credentials = ntwd;
smt.Port = 587;
smt.EnableSsl = true;
smt.Send(msg);
lblMessage.Text = "REGISTERED SUCCESSFULLY";
lblMessage.ForeColor = System.Drawing.Color.ForestGreen;
}

Leave a Reply

Your email address will not be published. Required fields are marked *