Jump to content
nooneclose

[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

Share this post


Link to post
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 2020-06-17 - Version 1.5.0.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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? 

Share this post


Link to post
Share on other sites

You just want to retrieve EntryID and Subject?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-06-17 - Version 1.5.0.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

I also want the guts of the email like the body, when it was sent and stuff. I'm trying to filter them by finding the emails with a certain subject. 

Share this post


Link to post
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 2020-06-17 - Version 1.5.0.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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) 

Share this post


Link to post
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 2020-06-17 - Version 1.5.0.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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?

 

Share this post


Link to post
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 2020-06-17 - Version 1.5.0.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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 2020-06-17 - Version 1.5.0.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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

Share this post


Link to post
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 2020-06-17 - Version 1.5.0.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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. 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By nooneclose
      Why can I not click on either of my input fields?
      #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 730, 437, 192, 124) ;GUISetFont(14, 800, 0, "MS Sans Serif") GUISetBkColor(0xC0DCC0) Global $Label1 = GUICtrlCreateLabel("Enter your Password. UserName is auto filled", 62, 40, 604, 41, $SS_CENTER) GUICtrlSetFont(-1, 26, 800, 0, "MS Sans Serif") Global $Label2 = GUICtrlCreateLabel("User Name:", 120, 130, 604, 31, $SS_LEFT) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") Global $Label3 = GUICtrlCreateLabel("Password:", 135, 210, 604, 31, $SS_LEFT) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") Global $Input1 = GUICtrlCreateInput(@UserName, 274, 130, 185, 32) GUICtrlSetFont(-1, 14, 800, 1, "MS Sans Serif") Global $Input2 = GUICtrlCreateInput("Password", 274, 210, 185, 32, $ES_PASSWORD) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") Global $OK = GUICtrlCreateButton("OK", 274, 270, 185, 57) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $OK Global $UserName = GUICtrlRead($Input1) Global $PassWord = GUICtrlRead($Input2) ExitLoop EndSwitch WEnd ; Delete the GUI window GUIDelete()  
    • By cruisepandey
      Hi, 
      I have a string like this : 
      Global $Msga = "urrent directory is /send.  (Submission of file with log number 29381077284 is confirmed)";
      I want to extract the number 29381077284  from the string. I did StringSplit to split based on "(" and then use space to reach there, But it's not a good choice. 
      Can anyone help me with regular expression to find the number from String using AutoIT. TIA
    • By nooneclose
      I want wanting to run multiple tests on my company website. Sadly the process I want to automate requires opening a File Explorer to add an attachment. Is there a way in to automate a Chrome opened File Explorer?
      (I am using webdriver to automate the other 99% of the process just fine. But when I have it click on attach file and chrome opens a file explorer I do not know how to handle it.) 
      Any help would be greatly appreciated. 
    • By cruisepandey
      Hi There ! 
      I have a script here : 
       
      ;Launch CMD
      Run("C:\Windows\System32\cmd.exe")
      sleep(2000)
      $cmdHandle = WinActivate("C:\Windows\System32\cmd.exe")
      Sleep(2000)
      ;Sending document
      ControlSend($cmdHandle, "", "", "ftp" & @CRLF)
      ControlSend($cmdHandle, "", "", "open" & @CRLF)
      Sleep(2000)
      ControlSend($cmdHandle, "", "", "first command" & @CRLF)
      Sleep(2000)
      ControlSend($cmdHandle, "", "", "second-coomand" & @CRLF)
       
      first-command and second-command I can't provide cause it's internal. I have complied this .au3 file into an exe and it does the work. But I need to invoke this with Java. Java code I have tried is : 
       
          ProcessBuilder pb = new ProcessBuilder("C:\\Users\\username\\eclipse-workspace\\Examples\\src\\com\\own\\examples\\etc.exe");
          pb.start();
          Thread.sleep(5000);
       
      Through java it just launches the cmd and nothing happens after that. Please help !!
    • By FUD
      hello 
      please i need help 
      i need to open link in default browser only one windows without duplicate if i try to open the same link 
       
      thanks 
×
×
  • Create New...