Jump to content

[SOLVED] What is error 0? _OL_ItemFind


Recommended Posts

@water I am getting this error for the first time ever. I have run my code well over 60 times and I'm a bit confused as to why I am sometimes getting this error now. 

Here is the code and the error message that popped up:

$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "EntryID,Subject", "", 1)
    If Not IsArray($aItems) Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

@error = 0, @extended: 0 at line 317

I tried looking in the OutLookEX UDF and there is no explanation of error 0

This is what the UDF says about "_OL_ItemFind"

Success: One based two-dimensional array with the properties specified by $sReturnProperties
Failure: Returns "" and sets @error:
    1 - You have to specifiy $sSearchName AND $sSearchValue or none of them
    2 - $sWarningClick not found
    3 - Error accessing the specified folder. See @extended for errorcode returned by _OL_FolderAccess
    4 - Error accessing specified property. @extended is set to the COM error
    5 - Error filtering items. @extended is set to the COM error
    1nmm - Error checking the $sReturnProperties as returned by __OL_CheckProperties. n is either 0 (property does not exist) or 1 (Property has invalid case)     mm is the index of the property in error (one based)

As always any help or suggestions will be greatly appreciated. 

Edited by nooneclose
Error was fixed
Link to comment
Share on other sites

That's a bug in the example script.
_OL_ItemFind returns an error but IsArray resets @error and @extended.

Replace line

If Not IsArray($aItems) Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

with

If @error <> 0 Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Thank you for getting back with me. I did as you said and now I am getting this error:

"@error = 4, @extended 2 at line 317"

so I am having this problem?

 4 - Error accessing specified property. @extended is set to the COM error

 Sometimes it runs the first time and sometimes five or six times before this error occurs. 

 how would I go about fixing it? 

Link to comment
Share on other sites

You just want to retrieve EntryID and Subject?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

When searching for emails you get more than just emails. You get receipts as well. They have a limited set of properties. So when you try to retrieve one of this (non existing) properties you get this error.
For the time being I suggest to just retrieve the EntryID by _OL_ItemFind and then call _OL_ItemGet for each returned item and retrieve the rest of the properties.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

@water so something like this?

$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "EntryID,Subject", "", 1)
    If @error <> 0 Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

    ; TEST an idea from water the maker of the outlookEX udf
    Global $aOL_Properties = _OL_ItemGet($oOutlook, $aItems[1][0])
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemGet Example Script", "Error accessing properties. @error = " & @error)
    _ArrayDisplay($aOL_Properties, "OutlookEX UDF: All properties of a contact item (name, value, datatype)", "", 0, "|", "Name|Value|Type")

    ; Retrieve the item's object
    $oItem = $oOutlook.Session.GetItemFromID($aItems[1][0], Default)
    $oItem.GetInspector

    $eBody          = $oItem.Body                                       ; The Body of the E-mail
    $eSenderAddress = $oItem.SenderEmailAddress                         ; Customers E-mail address
    $eSentOn        = $oItem.SentOn                                     ; When was the E-mail sent?
    $eSubject       = $oItem.Subject                                    ; Subject of the E-mail

Is it a bad idea to loop through the emails using a function that does the _OL_ItemFind() every time? (that is what im doing) 

Link to comment
Share on other sites

Something like this:

$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "EntryID", "", 1)
If @error <> 0 Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)
ReDim $aItems[Ubound($aItems, 1)][Ubound($aItems, 2) + 4] ; Extend the array to store the properties we retrieve below
; TEST an idea from water the maker of the outlookEX udf
For $i = 1 to $aItems[0][0]
    $oItem = _OL_ItemGet($oOutlook, $aItems[$i][0], Default, -1)
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemGet Example Script", "Error retrieving item object. @error = " & @error)
    $aItems[$i][1] = $oItem.Body                                       ; The Body of the E-mail
    $aItems[$i][2] = $oItem.SenderEmailAddress                         ; Customers E-mail address
    $aItems[$i][3] = $oItem.SentOn                                     ; When was the E-mail sent?
    $aItems[$i][4] = $oItem.Subject                                    ; Subject of the E-mail
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

No? I meant to say that I literally call this function after each email. (Are you telling me how I should do it or asking me how I loop it? I would rather do it your way, you are smarter :D)

Here is the function that I call once before looping and then loop each time after the first email has been processed.  

 

Func LoopUnreadEmails()

    $aFolder = _OL_FolderAccess($oOutlook, "*\Outlook-UDF-Test", $olFolderInbox)
    If @error Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

    $aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "EntryID,Subject", "", 1)
    If @error <> 0 Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

    Global $aOL_Properties = _OL_ItemGet($oOutlook, $aItems[1][0])
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemGet Example Script", "Error accessing properties. @error = " & @error)
    ;_ArrayDisplay($aOL_Properties, "OutlookEX UDF: All properties of a contact item (name, value, datatype)", "", 0, "|", "Name|Value|Type")

    $oItem = $oOutlook.Session.GetItemFromID($aItems[1][0], Default)
    $oItem.GetInspector

    $eBody          = $oItem.Body                                       ; The Body of the E-mail
    $eSenderAddress = $oItem.SenderEmailAddress                         ; Customers E-mail address
    $eSentOn        = $oItem.SentOn                                     ; When was the E-mail sent?
    $eSubject       = $oItem.Subject                                    ; Subject of the E-mail

    Local $ebroEmail1 = $eSenderAddress
    Local $eBroEmail2 = StringReplace($ebroEmail1, @CR, "")
    Local $eBroEmail3 = StringReplace($eBroEmail2, @LF, "")
    Local $eBroEmail4 = StringReplace($eBroEmail3, @TAB, "")
    $eSenderAddress   = StringReplace($eBroEmail4, @CRLF, "")

    If $eSubject = "SKIPPED Maintenance Request from Eagle's Nest" Then
        ConsoleWrite("Subject had 'skipped'" & " at line: " & @ScriptLineNumber & @CRLF)
        ChangeEmailStatus()
        $count += 1
        Loop()
    ElseIf $eSubject <> "Maintenance Request from Eagle's Nest" Then
        ConsoleWrite("Subject did not include 'maintenance request from eagles nest'" & " at line: " & @ScriptLineNumber & @CRLF)
        ChangeEmailSubject()
    EndIf
    
EndFunc

 

 I got a new error: @error = 3, @extended: 4 at line 343

Line 343 is the: "$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "EntryID,Subject", "", 1)"

Does outlookEX have known issues with WebDriver? I never got these errors until i upgraded my code to run with Webdriver?

 

Link to comment
Share on other sites

The error might be caused by accessing the folder twice: By _OL_FolderAccess and by specifying the folder in _OL_ItemFind as text. I suggest:

$aFolder = _OL_FolderAccess($oOutlook, "*\Outlook-UDF-Test", $olFolderInbox)
If @error Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

$aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "[UnRead]=True", "", "", "EntryID,Subject", "", 1)
If @error <> 0 Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

@water Do I even need this: line of code?

$aFolder = _OL_FolderAccess($oOutlook, "*\Outlook-UDF-Test", $olFolderInbox)
If @error Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

If I remove it would it work better? 

Edited by nooneclose
grammar
Link to comment
Share on other sites

Correct. Your original code

$aFolder = _OL_FolderAccess($oOutlook, "*\Outlook-UDF-Test", $olFolderInbox)
If @error Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "EntryID,Subject", "", 1)
If @error <> 0 Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

could be stripped down to

$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "EntryID,Subject", "", 1)
If @error <> 0 Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

@water I was able to capture that error again. Apparently it did not go away it is just that random. 

@error = 3, @extended: 4 at line 358 (same as line 2847)

This was the last thing on the OutPut before the code crashed.

We intercepted a COM Error !  Number: 0x 80020008
Description: Bad variable type.
At line: 1295

ElseIf StringRight($suite, 3) = 04 OR StringRight($suite, 3) = 06 Then

@AutoItVersion = 3.3.14.5
@AutoItX64 = 0
@Compiled = 0
@OSArch = X64
@OSVersion = WIN_10
Scriptline = 1295
Number = -2147352568
WinDescription = Bad variable type.
Description = 
Source = 
HelpFile = 
HelpContext = 
LastDllError = 0

 

@error = 3, @extended: 4 at line 2847

$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "EntryID,Subject", "", 1)
If @error <> 0 Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber)

 

This was the last thing that happened before the second crash. 

We intercepted a COM Error !  Number: 0x 80020008
Description: Bad variable type.
At line: 994

$oFolder = $oFolder.Folders($aFolders[$iIndex])

@AutoItVersion = 3.3.14.5
@AutoItX64 = 0
@Compiled = 0
@OSArch = X64
@OSVersion = WIN_10
Scriptline = 994
Number = -2147352568
WinDescription = Bad variable type.
Description = 
Source = 
HelpFile = 
HelpContext = 
LastDllError = 0

Edited by nooneclose
it happened again but in the stripped version
Link to comment
Share on other sites

Shouldn't this

ElseIf StringRight($suite, 3) = 04 OR StringRight($suite, 3) = 06 Then

be

ElseIf StringRight($suite, 3) = "04" OR StringRight($suite, 3) = "06" Then

and BTW this line will never raise a COM exception.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Surprisingly enough I just have numbers in those strings and plain 04 works. it doesn't give an error or break if I don't use "04".

I am no longer having these issues.

I forgot what I changed to fix it. I have changed my code so much over the last 24 hours that all error checking just blended together. 

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

×
×
  • Create New...