MS Access CDO电子邮件

时间:2016-02-29 16:06:06

标签: vba email ms-access cdo.message

我在MS Excel中成功使用此功能通过我们的服务器发送SMTP电子邮件

Dim imsg As Object
Dim iconf As Object
Dim strbody As String
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/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "our smtp mail server"
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Update
    End With

strbody = "Testing 123" & vbNewLine & vbNewLine & _
          "Thanks, I got the mail going already" & vbNewLine & _
          "and this email was sent through there with an" & vbNewLine & _
          "attachment to show that." & vbNewLine & _
          "XXX"

With imsg
    Set .Configuration = iconf
    .To = "sssss@gggggg.com"
    .CC = ""
    .BCC = ""
    .From = """Dan"" <xxx@zzzzz.COM>"
    .Subject = "Testing mail server"
    .TextBody = strbody
    .Send
End With

当我复制并粘贴到MS Access中的模块(我真的需要它)时,我得到了

运行时错误(80040213),传输无法连接到服务器

这里有什么?,谢谢

我正在使用MS Office 2010运行Win7。这些也在MS VBA参考

中启用

Windows 2000 Library的MS CDO MS DAO 3.6对象库 MS ActiveX数据对象2.8库 OLE自动化 MS Access 14对象库

0 个答案:

没有答案