使用CDO从VBA(MS Access)通过gmail发送电子邮件:传输无法连接到服务器
我发现以下代码,但它不工作使用CDO从VBA(MS Access)通过gmail发送电子邮件:传输无法连接到服务器,vba,gmail,cdo.message,Vba,Gmail,Cdo.message,我发现以下代码,但它不工作 Set cdomsg = CreateObject("CDO.message") With cdomsg.Configuration.Fields .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = MailSender
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = MailPassword
.Item("http://schemas.microsoft.com/cdo/configuration/urlproxyserver") = "xxx.xxx.x.xxx:8080"
.Update
End With
' build email parts
With cdomsg
.To = MailTo
.From = MailSender
.Subject = MailSubject
.TextBody = MailText
.Send
End With
Set cdomsg = Nothing
我得到了错误
The Transport Failed to connect to the Server
我在一个代理人后面,我试过有没有。错误是一样的。我不确定的是,是否需要IIS才能工作,因为在谷歌上搜索这个错误时,通常都是关于ASP和IIS的问题。我认为代码很好。这与为其他人工作的代码是一样的
其他潜在问题
编辑:
是否有一个工具可以让我获得有意义的错误消息
编辑:
从来没有让它工作过。公司改为gmail作为电子邮件提供商,我也并没有让它处理我的私人gmail代理问题?或者我的公司电子邮件现在链接到gmail谷歌商务。然而,该公司已经授权了chrome插件。有了这个插件,你就可以发送电子邮件,或者更好地说,affixa会在gmail中打开一个对话框,你必须手动按send 考虑过把时间设定得比10点长一点吗?没关系&0将导致相同的错误。将其设置得更低,以便在测试不同版本的代码时不必一直等待。您是否尝试过在不在代理(例如您的个人计算机)后面的计算机上运行代码?请尝试端口587而不是465,我在代码中使用它!尝试了两个端口,出现了相同的错误。