【问题标题】:mailing using microsoftonline使用 microsoftonline 邮寄
【发布时间】:2013-05-27 15:31:48
【问题描述】:

我正在尝试使用以下方法发送电子邮件。为了安全起见,此处未提供凭据。但他们是正确的。

    static void Main(string[] args)
    {
        string mailTo = "testmail@testmail.com";
        MailMessage mail = new MailMessage("email@email.onmicrosoft.com", mailTo);           

        mail.Subject = "Test";
        mail.Body = "Blank Email";
        mail.Priority = MailPriority.High;
        mail.IsBodyHtml = true;

        // Set the StmpServer name. 
        SmtpClient mailSmtp = new SmtpClient("Smtp.mail.microsoftonline.com");

        // Smtp configuration            
        mailSmtp.Credentials = new System.Net.NetworkCredential("email@email.onmicrosoft.com", "********");            
        mailSmtp.Port = 587;          
        mailSmtp.Timeout = 30000;
        try
        {
            mailSmtp.Send(mail);
        }
        catch(Exception ex) { 
            Console.WriteLine(ex.Message.ToString());
        }
    }

但这不起作用。 “Failur sent mail”是SmtpException捕获的消息。

我在设置凭据之前尝试过使用mailSmtp.UseDefaultCredentials = false;EnableSsltrueDeliverymethodNetwork。但一切都没有改变这种情况。

【问题讨论】:

  • 错误信息仅此而已?
  • 我在 InnerException 中收到了这条消息。 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 65.55.171.153:587
  • 在此处提供更多异常详情。
  • '无法连接到远程服务器' ... SocketErrorCode = System.Net.Sockets.SocketError.TimedOut NativeErrorCode = 10060

标签: c# email smtpclient


【解决方案1】:

确保您的 ISP 允许端口 25 的传出连接。如果端口 25 关闭,您将收到此错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-16
    • 2011-03-16
    相关资源
    最近更新 更多