lte5000 Posted January 12, 2009 Posted January 12, 2009 (edited) Hi,I'm trying to use the Ostrosoft SMTP component v7 with AutoIt v3.3.0.0 on Windows XP SP3.The component works fine with VBScript.In AutoIt I always get the following COM error: 0x8002000B - Invalid indexThe error occurs at this script line: ObjEvent($oSMTP, "oSMTP_")The email does get sent out successfully, but the script times out because the oSMTP_ events are never fired.Thanks for any assistance,Kendallvb script:expandcollapse popup'VBScript sample for OstroSoft SMTP Component Option Explicit Dim oSMTP 'As OSSMTP.SMTPSession Dim sStatus 'As String Dim bClose 'As Boolean Dim nTimeout 'As Long Dim n 'As Long sStatus = "" bClose = False nTimeout = 1000 n = 0 Set oSMTP = CreateObject("OSSMTP.SMTPSession") WScript.ConnectObject oSMTP, "oSMTP_" oSMTP.RaiseError = True oSMTP.Server = "mail server" oSMTP.AuthenticationType = 2 oSMTP.Username = "username" oSMTP.Password = "password" oSMTP.Port = 587 oSMTP.MailFrom = "email address" oSMTP.SendTo = "email address" oSMTP.MessageText = "test" oSMTP.MessageSubject = "test" oSMTP.SendEmail Sub oSMTP_ConnectSMTP() 'connected to mailserver End Sub Sub oSMTP_SendSMTP() 'message successfully sent End Sub Sub oSMTP_StatusChanged(ByVal Status) sStatus = sStatus & oSMTP.Status & vbCrLf End Sub Sub oSMTP_ErrorSMTP(ByVal Number, Description) 'error occured sStatus = sStatus & "Error " & Number & ": " & Description & vbCrLf bClose = True End Sub Sub oSMTP_CloseSMTP() 'connection to mailserver closed bClose = True End Sub Do While Not bClose WScript.Sleep 1 n = n + 1 If n > nTimeout Then sStatus = sStatus & "Timeout" & vbCrLf Exit Do End If Loop WScript.Echo sStatus Set oSMTP = NothingAutoIt:expandcollapse popupAutoItSetOption("MustDeclareVars", 1) Global $oMyRet[2], $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Dim $oSMTP Dim $sStatus Dim $bClose Dim $nTimeout Dim $n $sStatus = "" $bClose = 0 $nTimeout = 1000 $n = 0 $oSMTP = ObjCreate("OSSMTP_Plus.SMTPSession") ObjEvent($oSMTP, "oSMTP_") $oSMTP.RaiseError = True $oSMTP.Server = "mail server" $oSMTP.AuthenticationType = 2 $oSMTP.Username = "username" $oSMTP.Password = "password" $oSMTP.Port = 587 $oSMTP.MailFrom = "email address" $oSMTP.SendTo = "email address" $oSMTP.MessageText = "test" $oSMTP.MessageSubject = "test" $oSMTP.SendEmail () Func oSMTP_ConnectSMTP() ;connected to mailserver EndFunc;==>oSMTP_ConnectSMTP Func oSMTP_SendSMTP() ;message successfully sent EndFunc;==>oSMTP_SendSMTP Func oSMTP_StatusChanged($Status) $sStatus = $sStatus & $Status & @CRLF EndFunc;==>oSMTP_StatusChanged Func oSMTP_ErrorSMTP($Number, $Description) ;error occured $sStatus = $sStatus & "Error " & $Number & ": " & $Description & @CRLF $bClose = 1 EndFunc;==>oSMTP_ErrorSMTP Func oSMTP_CloseSMTP() ;connection to mailserver closed $bClose = 1 EndFunc;==>oSMTP_CloseSMTP While Not $bClose Sleep(15) $n = $n + 1 If $n > $nTimeout Then $sStatus = $sStatus & "Timeout" & @CRLF ExitLoop EndIf WEnd MsgBox(0, "", $sStatus) $oSMTP = "" ;custom defined error handler Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc Edited January 12, 2009 by lte5000
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now