Jump to content
nooneclose

[SOLVED] What is error 0? _OL_ItemFind

Recommended Posts

Posted (edited)

@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
Posted (edited)

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 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
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 (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - 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 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
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 (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - 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 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
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 (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - 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 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
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 (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - 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 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
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 (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - 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 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
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 (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - 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 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
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 (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - 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

  • Similar Content

    • By nooneclose
      Good morning, I am trying to figure out if it is possible to check if these invoice lines exist or not. 
      Here are the table and column name: INVOICELINE.INVOICELINENUM (a required field if created)
      Here is a picture of what I am talking about. (Do not worry about security. the picture is from a demo test site so all information is fake)
       
      is there any way to check if these fields exist or not? (they do not exist unless the user clicks on "New Row")
      Example: line 11 does not exist right now. How would I go about to see if it did or not? 
      This is what I have so far:
      SELECT DISTINCT iv.invoicenum, iv.description FROM invoice AS iv JOIN invoiceline AS ivl ON iv.invoicenum = ivl.invoicenum AND iv.siteid = ivl.siteid /* = 'nothing' and yet somehow not null? */ WHERE iv.invoicenum NOT IN (SELECT invoicelinenum FROM invoiceline WHERE invoicelinenum IS NOT NULL) I get 0 results where I should get more than 0. 
    • By Kruxe
      Hello Everyone,
      I am very green when it comes to AutoIT, I have recently started using it to automate a job that i perform using MS Excel and that is working great. Recently I have been faced with a challenge I which i need to copy a specific set of lines from one .txt file and past them, overwriting a specific set of lines in a different .txt file. I honestly have no clue how I can copy the specified lines and transfer them. What functions / commands could I use and how could I lay them out I AutoIT? Any and all help will be appreciated. 
      Thanks!
      Kruxe
    • By Saravanan2213
      Hi everyone,
      i just need your help. i have script for cleaning browsing history and other unwanted file but the problem is i don't want to see the GUI i have attached below. It should not show anything on the screen. is it possible to do it in autoit. thanks in advance.
       
      So for i have tried flag
      Run("rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 255", "", @SW_HIDE)
      @SW_DISABLE
       
      Looking forward your help.........

    • By cptHark
      Hello I want to conect to a Network with DriveMapAdd.
      This worked just fine but when you restart the Computer the Mapped drive is gone.
      So i used the persistent mapping flag and that seemed to work, too.
      However when the Computer is restarted I cant connect to the Network because it doesnt remember the Username and password I ave it the first time.
      How do I fix this?
      My Code:Func
      setdrivem()
          DriveMapAdd("M:", GUICtrlRead($driveM),1, GUICtrlRead($netzuser),GUICtrlRead($netzpassword) )
      EndFunc
      $netzuser and $netzpassword are set earlier in the gui and it works right after executing the script but i want it to stay connected
    • By nooneclose
      Morning, I am wondering is there is a way to prevent a script from ending/crashing when a "Subscript used on non-accessible variable" error occurs? 
      Here is some of my code:
      $aItems = _OL_ItemFind($oOutlook, $mFolder[1], $olMail, "[UnRead]=True", "Subject", "Maintenance Request", "EntryID,Subject", "", 0) If @error Then Sleep(2000) LoopUnreadEmails() ;Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended & " at line: " & @ScriptLineNumber) EndIf Error Msg:
      (371) : ==> Subscript used on non-accessible variable.: $aItems = _OL_ItemFind($oOutlook, $mFolder[1], $olMail, "[UnRead]=True", "Subject", "Maintenance Request", "EntryID,Subject", "", 0) $aItems = _OL_ItemFind($oOutlook, $mFolder^ ERROR I know that error occurs very rarely and at random. But like with most errors "in this case" I can use recursion to fix it. 
      I just recall the function and it will and has fixed itself. But this "Subscript used on non-accessible variable" just ends the script.
      Like I said before, is there a way to allow the script to keep running or call a function when this error occurs instead of just ending?   
×
×
  • Create New...