Jump to content

Recommended Posts

Posted (edited)

Hello everybody

I would ask if somebody can help me with this little script, what I want is if I send a mail and the mail is not send out what to do to have

some error checking on the mail is sent out or not send out. I can not find any info about that.

I need some error check to leave a message is sent or message is not sent.. What is the errorcode to do this?

Code:

/

$objMessage = ObjCreate("CDO.Message")

$objMessage.From = "Aktivate@info.com"

$objMessage.To = "Your mail@.com"

$objMessage.Subject = "Test message"

$objMessage.TextBody ="Hello world"

$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail1.telia.com"

$objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

$objMessage.Configuration.Fields.Update

$objMessage.Send

msgbox(4096,"", "The message is sent")

/

Edited by Borje
Posted

1) CDO.Message doesn't work on Win9x systems

2) use Error Handler

Global $oMyError = ObjEvent ("AutoIt.Error", "ErrorHandler")

Func ErrorHandler()
    $HexNumber = Hex($oMyError.number, 8)
        MsgBox(16, "CHYBA", "Při odesílání emailu došlo k chybě!" & @CRLF & @CRLF & _
            "Popis chyby: " & @TAB & $oMyError.description & @CRLF & _
            "Win. popis:" & @TAB & $oMyError.windescription & @CRLF & _
            "Číslo řádku: " & @TAB & $oMyError.scriptline & @CRLF & _
            "Číslo chyby: " & @TAB & $HexNumber & @CRLF & _
            "Objekt: " & @TAB & $oMyError.source)
        SetError(1)
    EndFunc

3) check @error after  ObjCreate()

$objMessage = ObjCreate ("CDO.Message")
    If @error Then ...
Posted

Thank you Zedna

I have test this but must ask the errorhandler is that in the beginning of the script?

I want with error that display the message is not sent, and with no error that display message is sent.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...