这是我在VBA上的实际代码......
Private Message As CDO.Message
Private Attachment, Expression, Matches, FilenameMatch, i
Sub enviar_mail()
Set Message = New CDO.Message
Message.Subject = "my subject here"
Message.From = "jhony.donosso@road-track.com"
Message.To = "jhony.donosso@road-track.com"
Message.TextBody = "my text body here"
Dim Configuration
Set Configuration = CreateObject("CDO.Configuration")
Configuration.Load -1 ' CDO Source Defaults
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "my_mail_server" 'A
'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 26
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "my_user"
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "my_pass"
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/urlproxyserver") = "my_url_proxy" 'B
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/urlproxyport") = "443" 'https
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/urlproxybypass") = "my_urlproxybypass" 'C
Configuration.Fields.Update
Set Message.Configuration = Configuration
Message.Send
End Sub
当我运行sub时,我收到此消息:传输无法连接到服务器。
答案 0 :(得分:1)
您尝试做什么不会工作,因为您查看MAPI / HTTP代理设置并尝试通过SMTP发送邮件(这是两种不同的协议)。因此,您需要使用Exchange服务器的实际SMTP设置(例如,它应该是端口25或客户端端口993),或者您可以查看使用EWS,如果您知道EWS端点,例如Office365
data.table