如何添加smtp hotmail帐户发送邮件

我写了一些代码,以便发送电子邮件但我只能从gmail帐户发送邮件到gmail帐户,我想使用hotmail帐户我该怎么办? 谢谢它是

SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("xxx@gmail.com"); mail.To.Add("kalaylevent@gmail.com"); mail.Subject = "Test Mail - 1"; mail.IsBodyHtml = true; string htmlBody; htmlBody = "Write some HTML code here"; mail.Body = htmlBody; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("kalaylevent@gmail.com", "mypassword"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); 

我更改了一些代码并测试成功(从Hotmail到Gmail)

 SmtpClient SmtpServer = new SmtpClient("smtp.live.com"); var mail = new MailMessage(); mail.From = new MailAddress("youremail@hotmail.com"); mail.To.Add("to@gmail.com"); mail.Subject = "Test Mail - 1"; mail.IsBodyHtml = true; string htmlBody; htmlBody = "Write some HTML code here"; mail.Body = htmlBody; SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("youremail@hotmail.com", "password"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail);