【问题标题】:Send CDO email using Outlook through excel VBA code通过 Excel VBA 代码使用 Outlook 发送 CDO 电子邮件
【发布时间】:2019-04-29 12:14:49
【问题描述】:

我有使用来自 Internet 的 CDO 发送电子邮件的代码 - 但我不断收到消息“传输无法连接到服务器”

我尝试了各种服务器交换的设置更改,但没有成功。

`````
strSubject = "Results from Excel Spreadsheet"
strFrom = "jceast7@hotmail.com"   '"rdube02@gmail.com"
strTo = "jceast7@hotmail.com"     '"rdube02@gmail.com"
strCc = ""
strBcc = ""
strBody = "The total results for this quarter are: "   '& Str

'STEP 3
'The next section of code is where you will configure CDO to use any
 external SMTP server to send the email.


Set CDO_Mail = CreateObject("CDO.Message")
On Error GoTo Error_Handling

Set CDO_Config = CreateObject("CDO.Configuration")
CDO_Config.Load -1

Set SMTP_Config = CDO_Config.Fields

With SMTP_Config
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "Microsoft Exchange"  '"smtp.hotmail.com"   '"smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
= 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "jceast7@hotmail.com"     '"email@website.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")
= "123456"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") 
= 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Update
End With

With CDO_Mail
Set .Configuration = CDO_Config
End With
``````

【问题讨论】:

标签: excel vba outlook


【解决方案1】:
 " The transport failed to connect to the server"

该错误意味着您需要在网站上登录您的帐户(Google 或其他) 并选择“允许外部程序使用电子邮件”(类似的东西),它对我有用,我和你在同一个地方!

【讨论】:

  • 我已登录到我的 Microsoft 帐户。我转到 Outlook,文件选项,此时我找不到任何显示“允许外部程序使用电子邮件”或类似内容的内容。在这一点上令人沮丧
  • 不在 Outlook 中,您需要登录到您的服务器帐户(例如 Microsoft 登录)
  • 非常感谢您的帮助 - 我不知道如何使用我的服务器帐户 - 但我会用谷歌搜索一下,看看我能找到什么。
猜你喜欢
  • 2017-11-05
  • 2023-01-07
  • 2016-01-18
  • 2016-01-05
  • 1970-01-01
  • 2016-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多