经典ASP电子邮件不能与Outlook SMTP中继一起使用

时间:2013-04-02 15:40:41

标签: email asp-classic smtp office365

我试图让经典的ASP页面与Outlook(Microsoft Web Email)SMTP中继一起使用。我收到以下错误:

CDO.Message.1 error '80040213'
The transport failed to connect to the server.

我的代码看起来像

dim objEmail                
Set objEmail = Server.CreateObject("cdo.message") 
objEmail.To = list
objEmail.From = "xyz@abc.com"  
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = username
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = password
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
objEmail.Configuration.Fields.Update
objEmail.Send

我使用GMAIL测试过,这个东西片段可以正常使用它。我想我在Outlook SMTP的配置中遗漏了一些东西

1 个答案:

答案 0 :(得分:0)

这是一个有效的例子。确保您使用的帐户有邮箱,而地址确实是帐户地址。

        ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

        var msg = new MailMessage();
        msg.Subject = "Hello";
        msg.Body = "Hello Sir";
        msg.From = new MailAddress("no.reply@contoso.com");
        msg.To.Add("user@contoso.com");

        var client = new SmtpClient("smtp.outlook.office365.com");
        client.Port = 587;
        client.Credentials = new NetworkCredential("no.reply@contoso.com", "******");
        client.EnableSsl = true;

        client.Send(msg);