【问题标题】:VBA CDO Runtime Error 429VBA CDO 运行时错误 429
【发布时间】:2013-09-05 21:03:00
【问题描述】:

让这个 vba 远程电子邮件发送脚本工作时遇到问题。

运行时错误 429 ActiveX 组件无法创建对象。

我已经下载了Microsoft CDO 1.21 Library,将cdo.dll cmd prompt注册为Administrator,并引用了它。

.dll 位置:C:\Program Files\ExchangeMapi\cdo.dll

操作系统:Windows 7 Professional,32 位,Service Pack 1。

使用 VBA 的应用程序:Iconics ScriptWorx32

代码:

Public Sub SendEmail(nFrom As String, nSubject As String, nOutGoingServer As String, _
                     nMessage As String, nPassword As String, nUserName As String, _
                     nServerPort As Long, nTo As String, Optional nIntProxyPort As Long)

  Dim Msg As Object
  Dim Confg As Object
  Dim Flds As Variant  

  Set Msg = CreateObject("CDO.Message")  
  Set Confg = CreateObject("CDO.Configuration")    

  Confg.Load -1
  Set Flds = Confg.Fields
  With Flds
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = nUserName 
      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = nPassword 
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = nOutGoingServer
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = nServerPort
      ' If using internet proxy
      .Item("http://schemas.microsoft.com/cdo/configuration/urlproxyserver") = nIntProxyPort 
     .Update
  End With

  nMessage = nMessage & vbNewLine & vbNewLine & _
  "THIS IS AN AUTOMATED REPSONSE FROM ADMIN"

  With Msg
      Set .Configuration = Confg
          .To = nTo
          .From = nFrom 
          .Subject = nSubject
          .TextBody = nMessage
          .Send
  End With

End sub

我想知道这个软件是否内置了某种 cdo.dll 类实例化块,所以你已经购买了他们的软件 GUI 版本。任何帮助都会很棒。谢谢。

【问题讨论】:

  • 哪一行报错?
  • @TimWilliams 对不起,我忘了补充:Set Msg = CreateObject
  • 你有两行这些行 - 哪一个错误?
  • 你能从(例如)Excel 中运行它吗?
  • @TimWilliams 这台机器没有 MS Office,这是许可的。我相信它有一个试用版的office。我可以试试看。感谢您的建议。

标签: vba plc scada


【解决方案1】:

我通过使用不同的库解决了这个问题:cdosys.dll 而不是 cdo.dll,参考:Microsoft CDO For Windows 2000 Library。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多