我正在开发可发送电子邮件的应用程序。我已经在hotmail上创建了帐户。
这是我的代码:

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("[email protected]", "pass");
            mailMessage.Subject = emailType.EmailSubject;
            smtpClient.Send(mailMessage);
        }
    }
}
catch (Exception ex)
{}


但这给了我例外:


  信箱不可用。服务器响应为:5.3.4未执行请求的操作;我们注意到您的Hotmail帐户中发生了一些异常活动。为了保护您,我们暂时禁止了您的帐户。


我不想使用Gmail,因为它需要电话号码。如何使用hotmail做到这一点?
谢谢

最佳答案

尝试这个。它对我的工作。

        SmtpClient SmtpServer = new SmtpClient("smtp.live.com");
        var mail = new MailMessage();
        mail.From = new MailAddress("[email protected]");
        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 protected]", "YourPassword");
        SmtpServer.EnableSsl = true;
        SmtpServer.Send(mail);

10-08 08:02