【问题标题】:VBA send Email over proxy with credentialsVBA 使用凭据通过代理发送电子邮件
【发布时间】:2017-04-24 19:56:29
【问题描述】:

我有一个需要凭据、用户名和密码的 Internet 代理服务器... 当我使用 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)

我认为那是为了代理......

有什么解决办法吗?

【问题讨论】:

    标签: vba proxy


    【解决方案1】:

    如果你在代理后面,你可以试试这个:

    .Item("http://schemas.microsoft.com/cdo/configuration/urlproxyserver") = "proxy"
    .Item("http://schemas.microsoft.com/cdo/configuration/proxyserverport") = 8080
    

    【讨论】:

    • 我会尝试...但是您在哪里输入代理用户和密码?
    • 我相信您没有使用 CDO 的选项(需要身份验证的代理服务器)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-08
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-07
    相关资源
    最近更新 更多