Thursday, 26 June 2014

Mailing System(Sending confirmation mail for Complaints or vallidation messge sending vai mail)

//First we add namespaces
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;
using System.Net.Mail;

  protected void SendMail()      // Function for sending confirmation mail to customers
    {
   try
        {

            MailMessage msg = new MailMessage("Email address of sender", Email address of receiver, "Subject", " Message for receiver");
            msg.IsBodyHtml = true;
            SmtpClient clnt = new SmtpClient();
            clnt.Host = "smtp.gmail.com";
            clnt.Port = 587;
            clnt.EnableSsl = true;
            NetworkCredential crd = new NetworkCredential("Email address of sender", "Password of sender");
            clnt.Credentials = crd;
            clnt.Send(msg);
            Label4.Text = "Successfully Sent";
}
        catch (Exception)
        {
            Label4.Text = "There is some error plzzz try again later";
        }
 
    }

No comments:

Post a Comment