2015-09-25 151 views
1

关于经典ASP和Office 365有几个问题,但似乎没有回答我的特定情况,所以在这里。办公室365和经典ASP与VB.net SMTP设置

我建立一个电子邮件帐户的Office 365,我试图做一个SMTP测试用下面的代码:

Dim ObjSendMail, mailSubject, mailBody 
Set ObjSendMail = CreateObject("CDO.Message") 
mailSubject = "Test" 
mailBody = "Test" 
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com" 
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 240 
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]" 
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" 
ObjSendMail.Configuration.Fields.Update 

ObjSendMail.To = "[email protected]" 
ObjSendMail.Subject = mailSubject 
ObjSendMail.From = """From Name"" <[email protected]>" 
'ObjSendMail.HTMLBody = "this is the body" 
ObjSendMail.TextBody = mailBody 
ObjSendMail.Send 

这会产生以下错误:

CDO.Message.1错误“ 80040213'

传输失败连接到服务器。

我已经知道这是由于smtpusessl设置,但我需要,如果我把它关闭,我会得到错误“8004020e”。

现在,这里的奇怪的事情......我能做成功地利用VB.net和下面的代码SMTP测试:

Dim mailClient As New SmtpClient("smtp.office365.com") 
    mailClient.Port = 587 
    mailClient.EnableSsl = True 
    'Your network credentials are going to be the Office 365 email address and the password 
    Dim cred As New System.Net.NetworkCredential("[email protected]", "password") 
    mailClient.Credentials = cred 
    Dim message As New MailMessage() 
    message.From = New MailAddress("[email protected]", "From Name") 
    message.[To].Add("[email protected]") 
    message.Subject = "Test Office 365 SMTP" 
    message.Body = "Test Body" 
    mailClient.Send(message) 

这告诉我,我不应该需要在配置我的东西服务器,以获得经典的ASP版本工作......这是我工作的网站是内置的。我的问题是...我错过了什么愚蠢的设置将摆脱运输错误?

谢谢。

+0

右键 - 您不需要在Office 365端配置任何能够通过ASP.NET发送电子邮件的东西。我有点困惑 - 为什么要问关于修复传输错误,如果它可以正常使用vb代码? – Andarta

+0

因为ASP.net代码是测试代码,以查看我是否拥有正确的身份验证凭证,服务器等。我正在使用的购物车内置经典ASP。 – SEFL

回答

4

尝试使用端口25而不是587.所有其他设置(包括smtpusessl)都可以保持不变。

我怀疑端口587的问题是CDO.Message不支持所需的协议(TLS?MSA?)。我发现了一些其他的网络帖子,说明与ASP/VBScript和端口587相同的问题,但.NET应用程序没有这个问题。

+0

好吧,那很奇怪......我特别使用了587,因为这就是关于Office 365的每个指令所说的。你说得对,虽然...... 25有效。我从来没有看到过这些帖子,但是这绝对可以解决它。谢啦。 – SEFL

+0

我有完全相同的问题,但尝试端口25也结束了相同的错误 CDO.Message.1错误'80040213' 传输失败连接到服务器。 还有什么可能导致问题? – chenks