Wednesday 18 June 2014

Send Mail by hotmail

Send Mail by hotmail

protected void SendMail()
    {

        SmtpClient SmtpServer = new SmtpClient("smtp.live.com");
        var mail = new MailMessage();
        mail.From = new MailAddress("xxx@hotmail.com");
        mail.To.Add("xxx@gmail.com");
        mail.Subject = "Your Sub";
        mail.IsBodyHtml = true;
        string htmlBody;
        htmlBody = "HTML code";
        mail.Body = htmlBody;
        SmtpServer.Port = 587;
        SmtpServer.UseDefaultCredentials = false;
        SmtpServer.Credentials = new System.Net.NetworkCredential("xxx@hotmail.com", "xxxxxx");
        SmtpServer.EnableSsl = true;
        SmtpServer.Send(mail);
    }