我知道有很多主题,但是我尝试过的所有内容似乎都不起作用,我正在使用以下代码发送电子邮件
Dim Mail As CDO.Message
Set Mail = New CDO.Message
'Enable SSL Authentication
Mail.Configuration.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Make SMTP authentication Enabled=true (1)
Mail.Configuration.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'Set the SMTP server and port Details
Mail.Configuration.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
Mail.Configuration.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
Mail.Configuration.fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Set your credentials of your Gmail Account
Mail.Configuration.fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxx@gmail.com"
Mail.Configuration.fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxx"
'Set All Email Properties
With Mail
.Subject = "Write subject here"
.From = "xxx@gmail.com"
.To = "xxx@hotmail.co.uk"
.CC = ""
.BCC = ""
.TextBody = "Test Mail"
End With
Mail.Configuration.fields.Update
'to send the mail
Mail.Send
我收到错误消息:
运行时错误'-2147220973(80040213(': 传输无法连接到服务器
我尝试过
我似乎无法使其正常工作。