Jump to content

Outlook UDF - Querying Email Based on Date using _OL_ItemFind


tczbu
 Share

Recommended Posts

I have a script that pulls all email from the inbox with a date later than X.  It was working great until recently.  I'm unable to find the right date format, or code, to make it work. 

I've also tried pulling all emails without a filter, and that is not working as of recently either.

Does anyone know how to properly return emails later than a date? Or, return all emails without a filter?  Please help! 

Thanks!

 

#include <OutlookEX.au3>

;$sFilter = "[CreationTime]>'2020-10-06 00:00'" ;This one doesn't work, gives error.

;$sFilter = "[CreationTime]>'202010060000'" ;This one shows an empty array.
;$sFilter = "[CreationTime]>'20201006000000'" ;This one shows an empty array.
;$sFilter= "[UnRead]=True" ; This one works
$sFilter = "" ;This one doesn't work, gives error.
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
$aInboxEmails = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, $sFilter, "", "", "EntryID,SenderEmailAddress,CreationTime,Subject,Body", "")
If @error = 0 Then
   _ArrayDisplay($aInboxEmails, "OutlookEX UDF: _OL_ItemFind")
Else
   MsgBox(16, "OutlookEX UDF: _OL_ItemFind", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended)
EndIf

 

Link to comment
Share on other sites

Please have a look at the wiki for the date format needed.
You are talking about errors you get. Please provide this error information.

Edit:
This is true when trying to pull all emails without filter too. Whats the value of @error and @extended after _OL_ItemFind?
Please add

_OL_ErrorNotify(2)

after _OL_Open to grab all COM errors and display detailed error information:

Edited by water

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

  • 2 weeks later...

The script started working again.  The only thing I can think of that changed is the number of emails in my inbox.  I think I had about 1500 emails in my inbox before.  I cleaned it up, and now I only have about 750.  Is there a limit on the number of emails the _OL_ItemFind function can handle?

Thanks for the reply!

Link to comment
Share on other sites

Exactly. There seems to be a limit for the number of items Outlook can open simultaneously as described here.

The solution is to drop those properties that keep the item open.

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...