Jump to content
Sign in to follow this  
gfcaim

Error Handling

Recommended Posts

gfcaim

I'm trying to learn the language, and of course error handling is a big part. I have an error handler working using 'objevent' but want to capture specific events. The help file states "To receive a specific event, create an AutoIt function name using the given prefix appended with the event name." but I don't follow what is meant...

Could some one please advise (I have searched the forum and read stuff but its not sinking in :mellow: ) Is there any descent tutorials that wil enlighten me?


[font="Comic Sans MS"]"I'm not usually a praying man, but if you are up there, please save me Superman!" (Homer J. Simpson)[/font]

Share this post


Link to post
Share on other sites
Mat

That info is for objects, so is useless to do what you want it to do.

Read up about the @error flag in the helpfile. That is the main way to do error checking in AutoIt

Share this post


Link to post
Share on other sites
gfcaim

That info is for objects, so is useless to do what you want it to do.

Read up about the @error flag in the helpfile. That is the main way to do error checking in AutoIt

Thanks Mat, thats really helpful and got me going again :mellow:


[font="Comic Sans MS"]"I'm not usually a praying man, but if you are up there, please save me Superman!" (Homer J. Simpson)[/font]

Share this post


Link to post
Share on other sites
gfcaim

Sorry to bring this up again chaps, but I'm afraid I'm not getting it :blink:

The error would occur on the '.send' line (if, for example, the email address was invalid) but thats where it bombs out so doesn't actually continue to the next line...

Func SendEmail($eTo,$eCC,$eSubj,$eBody)
    Local $olMailItem = 0
    Local $olByValue = 1
    $oOApp = ObjCreate("Outlook.Application")
    $oOMail = $oOApp.CreateItem ($olMailItem)
    $Res=true
    With $oOMail
        .To = $eTo
        .CC = $eCC
        .Subject = $eSubj
        .Body = $eBody
        .BodyFormat = 2;Plain=1, HTML=2, RichText=3
        .Importance = 1;Low=0, Normal=1, High=2
        .Send
        if @error=0 then
            $res=True
        Else
            $res=False
        EndIf
    EndWith
    $oOApp=0
EndFunc

[font="Comic Sans MS"]"I'm not usually a praying man, but if you are up there, please save me Superman!" (Homer J. Simpson)[/font]

Share this post


Link to post
Share on other sites
water

Please have a look at the Outlook UDF. The function _OutlookSendMail should give you an idea how it works.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×