通过Hotmail的电子邮件发送到Gmail [英] Send email via Hotmail to gmail
本文介绍了通过Hotmail的电子邮件发送到Gmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作的应用程序,它发送电子邮件。我的hotmail上创建的帐户。
这是我的代码:
I'm working on app, which sends emails. I've created account on hotmail. This is my code:
try
{
using (var smtpClient = new SmtpClient())
{
var mailAddressTo = new MailAddress(emailType.EmailAddress);
var mailAddressFrom = new MailAddress("id");
using (var mailMessage = new MailMessage(mailAddressFrom, mailAddressTo))
{
smtpClient.Host = "smtp.live.com";
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.Credentials = new NetworkCredential("id@hotmail.com", "pass");
mailMessage.Subject = emailType.EmailSubject;
smtpClient.Send(mailMessage);
}
}
}
catch (Exception ex)
{}
但它给了我异常:
邮箱无法使用。服务器响应为:不采取5.3.4请求的操作;我们注意到,在您的Hotmail帐户的一些不寻常的活动。为了帮助保护您,我们已经暂时封锁您的帐户。
Mailbox unavailable. The server response was: 5.3.4 Requested action not taken; We noticed some unusual activity in your Hotmail account. To help protect you, we've temporarily blocked your account.
我不想使用Gmail,因为它需要的电话号码。我怎样才能做到这一点与Hotmail的?
感谢
I don't wanna use Gmail, because it requires phone number. How can i do that with hotmail? thanks
推荐答案
试试这个。它为我工作。
Try this. its work for me.
SmtpClient SmtpServer = new SmtpClient("smtp.live.com");
var mail = new MailMessage();
mail.From = new MailAddress("email@hotmail.com");
mail.To.Add("ToGmail.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("email@hotmail.com", "YourPassword");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
这篇关于通过Hotmail的电子邮件发送到Gmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文