Live Traffic Feed

A visitor from Yekaterinburg viewed 'Vimal Vataliya' 5 days 3 hrs ago
A visitor from Voronezh viewed 'filter row datagrid with multiple column on keyup ' 22 days 7 hrs ago
A visitor from St petersburg viewed 'Vimal Vataliya' 23 days 19 hrs ago
A visitor from Boardman viewed 'Vimal Vataliya' 23 days 19 hrs ago
A visitor from Virginia viewed 'Vimal Vataliya' 23 days 19 hrs ago
A visitor from Washington viewed 'filter row datagrid with multiple column on keyup ' 24 days 2 hrs ago
A visitor from Gatchina viewed 'filter row datagrid with multiple column on keyup ' 25 days 14 hrs ago
A visitor from Yekaterinburg viewed 'Open Source cryptocurrency Exchanges | Vimal Vatal' 27 days 10 hrs ago
A visitor from Gatchina viewed 'Open Source cryptocurrency Exchanges | Vimal Vatal' 29 days 23 hrs ago
A visitor from Omsk viewed 'Open Source cryptocurrency Exchanges | Vimal Vatal' 1 month 4 days ago

Tuesday, December 16, 2014

how to send mail from our domain email id in asp.net C#

Leave a Comment
First paste this code to web.config file in configuration section:

<system.net>
    <mailSettings>
      <smtp>

        <network host="mail.abc.com" userName="XYZ@abc.com" password="yourPassword"/>

      </smtp>
    </mailSettings>
  </system.net>


Function for sending the mail:

try
        {
            System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage();
            //From Email Id.. custom domain
            System.Net.Mail.MailAddress fromAdd = new System.Net.Mail.MailAddress("xyz@abc.com");
            mailMsg.From = fromAdd;
            //Add Receiver's Email
            mailMsg.To.Add("ToEmail@Xyz.Abc");

            mailMsg.IsBodyHtml = true;
            mailMsg.Priority = MailPriority.High;

            mailMsg.Subject = "Your Subject";//subject of ur mail
            mailMsg.Body = @"Your Message as html or plain text";

            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();

            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

            smtp.Send(mailMsg);

        }
        catch (Exception ex)
        {
            Console.WriteLine("{0} Exception caught.", ex);
        }



If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment