Asp.Net

Tuesday, 27 August 2013

simple mail send

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

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

    }
    public void SendMailtoEmployee()
    {
        var fromAddress = "naveenkc2@gmail.com";

        var toAddress = "naveenkc2@gmail.com";

        const string fromPassword = "naveenkc@kit";

        string subject = "Hi! Mail From Dialಮಾಡಿ.com, Your Login Details";

        string body = "  WelCome to Dialಮಾಡಿ.com";

        var smtp = new System.Net.Mail.SmtpClient();
        {
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
            smtp.Timeout = 20000;
        }
        smtp.Send(fromAddress, toAddress, subject, body);
    }
}

No comments:

Post a Comment