我有一个需要凭据,用户和密码的互联网代理服务器...... 当我使用MSXML2.ServerXMLHTTP.6.0时,我可以设置setProxyCredentials
Dim url, xhr
url = "https://www.example.com/"
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xhr.Open "GET", url, False
xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xhr.setProxy 2, "proxy:8080"
xhr.setProxyCredentials "user", "password" ' <--- Here i set the proxy credentials
xhr.Send
MsgBox xhr.responseText
但是当我使用CDO时,我无法设置它并向我提出错误......
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/URLGetLatestVersion") = True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "gmailUser"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "GmailPasswor"
.Item("http://schemas.microsoft.com/cdo/configuration/urlproxyserver") = "proxy:8080"
.Update
End With
' build email parts
With cdomsg
.To = "mail@gmail"
.From = "mail@gmail"
.Subject = "the email subject"
.TextBody = "the full message body goes here. you may want to create a variable to hold the text"
.Send
错误-2147220973(80040213)
我认为那是代理....
有什么解决方法吗?
答案 0 :(得分:0)
如果您在代理服务器后面,可以试试这个:
.Item("http://schemas.microsoft.com/cdo/configuration/urlproxyserver") = "proxy"
.Item("http://schemas.microsoft.com/cdo/configuration/proxyserverport") = 8080