VBA CDO运行时错误429

时间:2013-09-05 21:03:00

标签: vba plc scada

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

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

我已经下载了Microsoft CDO 1.21 Library,以管理员身份注册了cdo.dll cmd提示符,并引用了它。

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

操作系统:Windows 7专业版,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版本。任何帮助都会很棒。感谢。

1 个答案:

答案 0 :(得分:0)

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