如何添加SMTP Hotmail帐户发送邮件发送邮件、帐户、SMTP、Hotmail

2023-09-02 21:33:44 作者:住进你梦里

我写了一些codeS,以发送电子邮件的邮件,但我只能发送邮件从Gmail帐户的Gmail帐户还,我想使用的Hotmail帐户我该怎么办呢?谢谢 这是

  SmtpClient SMTPSERVER =新SmtpClient(smtp.gmail.com);
mail.From =新MailAddress(kalaylevent@gmail.com);
mail.To.Add(kalaylevent@gmail.com);
mail.Subject =测试邮件 -  1;
mail.IsBodyHtml = TRUE;
串htmlBody;
htmlBody =写一些HTML code在这里;
mail.Body = htmlBody;
SmtpServer.Port = 587;
SmtpServer.Credentials =新System.Net.NetworkCredential(kalaylevent@gmail.com,输入mypassword);
SmtpServer.EnableSsl = TRUE;
SmtpServer.Send(邮件);
 

解决方案

我改变一点点的code和试验的成功(从Hotmail到Gmail)

  SmtpClient SMTPSERVER =新SmtpClient(smtp.live.com);
VAR邮件=新MailMessage();
mail.From =新MailAddress(youremail@hotmail.com);
mail.To.Add(to@gmail.com);
mail.Subject =测试邮件 -  1;
mail.IsBodyHtml = TRUE;
串htmlBody;
htmlBody =写一些HTML code在这里;
mail.Body = htmlBody;
SmtpServer.Port = 587;
SmtpServer.UseDefaultCredentials = FALSE;
SmtpServer.Credentials =新System.Net.NetworkCredential(youremail@hotmail.com,密码);
SmtpServer.EnableSsl = TRUE;
SmtpServer.Send(邮件);
 

smtp 发送 hotmail WordPress安装SMTP实现发送邮件功能

I wrote some codes so as to send e mail but I can only send mail from gmail account to gmail account also, I want to use hotmail accounts how can i do it? thanks It is

SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("kalaylevent@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);

解决方案

I changed a little of code and test success(from Hotmail to 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);