Office 365和经典的ASP与VB.net SMTP设置 [英] Office 365 and Classic ASP vs. VB.net SMTP Settings

查看:2383
本文介绍了Office 365和经典的ASP与VB.net SMTP设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大约有传统的ASP和Office 365,但没有几个问题,似乎回答我的特殊情况,所以这里去。

There are several questions about classic ASP and Office 365, but none that seem to answer my particular scenario, so here goes.

我成立了Office 365的电子邮件帐户,我试图做以下code的SMTP测试:

I set up an email account on Office 365 and am trying to do an SMTP test with the following code:

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@domain.com"
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
ObjSendMail.Configuration.Fields.Update

ObjSendMail.To = "to_email@anotherdomain.com"
ObjSendMail.Subject = mailSubject
ObjSendMail.From = """From Name"" <email@domain.com>"
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = mailBody
ObjSendMail.Send

这会生成以下错误:

CDO.Message.1错误'80040213'

CDO.Message.1 error '80040213'

的传输未能连接到服务器。

The transport failed to connect to the server.

我已经想通了,这是由于smtpusessl设置,但我需要的是,如果我把它关掉,我得到错误'8004020e'。

I've figured out that it's due to the smtpusessl setting, but I need that, and if I turn it off I get error '8004020e'.

现在,这里的奇怪的事情......我能成功地利用做SMTP测试VB.net和低于code:

Now, here's the weird thing...I can do the SMTP test successfully using VB.net and the code below:

    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@domain.com", "password")
    mailClient.Credentials = cred
    Dim message As New MailMessage()
    message.From = New MailAddress("email@domain.com", "From Name")
    message.[To].Add("to_email@anotherdomain.com")
    message.Subject = "Test Office 365 SMTP"
    message.Body = "Test Body"
    mailClient.Send(message)

这告诉我,我不应该需要我的服务器,以获得传统的ASP版本的工作......这就是我工作的网站是建立在任何配置。我的问题是... 。什么愚蠢的设置我缺少的,这将摆脱对传输错误的?

This tells me that I shouldn't need to configure anything on my server to get the classic ASP version to work...which is what the site I'm working on is built in. The question I have is...what stupid setting am I missing that will get rid of the transport error?

感谢。

推荐答案

尝试端口25,而不是587.您所有的其他设置,包括smtpusessl,可以保持不变。

Try port 25 instead of 587. All of your other settings, including smtpusessl, can remain the same.

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

I suspect the problem with port 587 is that CDO.Message doesn't support the protocol required (TLS? MSA?). I found a few other internet posts stating the same problem with ASP/VBScript and port 587 but that .NET applications did not have this problem.

这篇关于Office 365和经典的ASP与VB.net SMTP设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆