我正在尝试在Excel文件中设置用户表单,该文件发送电子邮件以报告用户使用电子表格找到的任何错误/问题。
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "bugreporter@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'smtp mail server
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'stmp server
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "example@domain.com"
.From = "bugreporter@gmail.com"
.Subject = "Hello"
.TextBody = "Hi Dude"
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
我收到错误"传输无法连接到服务器"。我不太了解端口/端口转发,但我尝试过端口25,465和587,但没有一个工作。我是从工作网络运行的,但我假设至少有一个端口必须打开,因为我们在所有人的计算机上运行Outlook。
我已在Gmail帐户上启用了IMTP,并允许安全性较低的应用。