我有Excel代码,它使用CDO使用smtp.office 365.com发送电子邮件。在过去的5年里,这种做法一直有效,但在2021年10月突然停止了工作。
错误处理返回:
有趣的是,当Excel表在任何其他工作站上使用时,代码仍然按预期工作。我已经重新安装了Office和Windows,认为这肯定是一个与PC相关的问题。然而,这一问题仍然存在。
我可以使用PowerShell在同一个工作站上使用相同的服务器、端口和凭据发送电子邮件。
代码:
Const cdoSendUsingPort = 2 ' Send the message using SMTP
Const cdoBasicAuth = 1 ' Clear-text authentication
Const cdoTimeout = 60 ' Timeout for SMTP in seconds
Const mailServer = "smtp.office365.com"
Const SMTPport = 25
Const mailusername =
Const mailpassword =
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPport
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = cdoTimeout
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailusername
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailpassword
.Update
End With
我不太清楚如何进一步解决这一问题。我最初认为这可能与被封锁的港口或某种腐败有关。我已经格式化了PC,重新安装了Windows和Office。
发布于 2022-01-07 07:53:12
Windows 10 Pro与Office 2019 Professional之间似乎存在冲突,smtp.office 365.com使用端口25。
如前所述,我有几个PC与Windows 10 Pro/Home和Office 2019和Office 365的组合,所有这些工作。但是,Office2019 Professional和Windows 10 Pro的特定组合会引发问题。即使CDO在Excel之外使用(使用python脚本),也是如此。
故障排除:
G29
下一步是看看进入21H2和Office 365是否仍然有效。
奇怪的是,没有端口在特定的机器上显示为阻塞,没有端口被ISP阻塞,所以Office 2019必须对CDO或端口做些什么--我不知道如何识别
发布于 2022-03-02 01:03:54
尝试将下面的配置字段添加到正在设置的配置字段中:
.Item("http://schemas.microsoft.com/cdo/configuration/sendtls") = True
另外,尝试将端口从25更改为465或587。
https://stackoverflow.com/questions/70595229
复制相似问题