本文介绍了如何添加SMTP Hotmail帐户发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

解决方案

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

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

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("[email protected]");
mail.To.Add("[email protected]");
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("[email protected]", "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("[email protected]");
mail.To.Add("[email protected]");
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("[email protected]", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);

这篇关于如何添加SMTP Hotmail帐户发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 06:30