Jump to content
tczbu

Outlook UDF - Querying Email Based on Date using _OL_ItemFind

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

 

Share this post


Link to post
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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (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

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!

Share this post


Link to post
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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (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

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.

×
×
  • Create New...