Jump to content

Error Handling


Recommended Posts

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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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