Sign in to follow this  
Followers 0
Borje

[ SOLVED ] I need little help with CDO Message

7 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



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 ...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Lovely language Zedna.

@Borje, just use your brains.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

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.

You may set-up some helper globar variable $com_error = True and test it in your main script.

Share this post


Link to post
Share on other sites

Thank you Zedna

I have that to work now after some tests thanks again.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0