Sign in to follow this  
Followers 0
satanico64

Bug with date with OutlookEX UDF, _OL_ItemFind ? [Resolved]

4 posts in this topic

#1 ·  Posted (edited)

Hi people ! :bye:

How are you  ?

well ? goood

here we go :geek: :

In december I've made a script based on Outlook Ex UDF, and i've got a problem.

My script list mails from outlook between 2 dates, and this worked well.

But with this new year, i'v got a bug, when the day is between the 1 and the 9 of the month.

ALL is detailled in my .au3 joined or code.

Example which is working:

$listofmailInbox = _OL_ItemFind($oOutlook, $Folder[1], $olMail, "[ReceivedTime]>'2013-12-26 10:00' And [ReceivedTime]<'2014-01-07 16:59'", "", "", "ConversationTopic,SenderName,CreationTime,Body,EntryID", "CreationTime,True", 1)

=> Search between 2013-12-26 and 2014-01-07 all is ok, i've got hundreds of result. in my array.

But when my first date is 2014-01-02 this script doesnt match anything. I just change the number of the date:

THIS DOESNT WORK: (same thing as above except date).

$listofmailInbox = _OL_ItemFind($oOutlook, $Folder[1], $olMail, "[ReceivedTime]>'2014-01-02 10:00' And [ReceivedTime]<'2014-01-07 16:59'", "", "", "ConversationTopic,SenderName,CreationTime,Body,EntryID", "CreationTime,True", 1)

During creation of my script i wanted to check during 5 days, so i was doing @MDAY - 5

If @mday = 09 then  @mday - 5 give 4 (and not 04). I thought first it was the problem, but forcing the date with number, as in my script it just doesnt work.

(many include, and variable in my code because i reduced it to post)

Code:

#include <GUIConstantsEx.au3>
#include <ListviewConstants.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <OutlookEX.au3>
#include <GuiEdit.au3>
#include <Constants.au3>
#include <Array.au3>

Global $TrayTooltip, $DOSSIER_Outlook, $Nombredejours, $OptionNotifTempsReel, $date, $hListView = -9999, $hZoneDeTexte = -9999, $hGUI = -9999, $LabCas = 0, $LabOuvrirMail = 0

Global $oMyError = ObjEvent("AutoIt.Error", "_ErrorHTTP"); Interception des erreurs autoit !!
Global $oOutlook, $oOApp = ObjCreate("Outlook.Application")
Global $test = ObjEvent($oOApp, "oOApp_")
Global $listofmail, $listofmailInbox ;

While 1
 Listes_mails()
 Exit
    Sleep(100)
WEnd


Func Listes_mails()
    ConsoleWrite("Listes_mails() " & @crlf )
    Local $Folder
    Local $oOutlook = _OL_Open()
    $Folder = _OL_FolderAccess($oOutlook, "", $olFolderInbox)

    ; THIS REQUEST IS OK:
    $listofmailInbox = _OL_ItemFind($oOutlook, $Folder[1], $olMail, "[ReceivedTime]>'2013-12-26 10:00' And [ReceivedTime]<'2014-01-07 16:59'", "", "", "ConversationTopic,SenderName,CreationTime,Body,EntryID", "CreationTime,True", 1)
    ConsoleWrite("Size of array: Ubound($listofmailInbox):" & UBound($listofmailInbox) & "||" & UBound($listofmailInbox,2) & @crlf )

;~  _ArrayDisplay($listofmailInbox)   ; Uncomment to display result.
;~  msgbox(1,"","Just to make a pause between requests")

    $listofmailInbox = ''; reset array
    ; THIS NEXT REQUEST IS NOT OK, ONLY FIRST DATE CHANGE. FROM '2013-12-26 10:00' to '2014-01-02 10:00'
    ConsoleWrite("!! Next request !!" & @CRLF)
    $listofmailInbox = _OL_ItemFind($oOutlook, $Folder[1], $olMail, "[ReceivedTime]>'2014-01-02 10:00' And [ReceivedTime]<'2014-01-07 16:59'", "", "", "ConversationTopic,SenderName,CreationTime,Body,EntryID", "CreationTime,True", 1)
    ConsoleWrite("Size of array: Ubound($listofmailInbox):" & UBound($listofmailInbox) & "||" & UBound($listofmailInbox,2)& @crlf)
;~  _ArrayDisplay($listofmailInbox)   ; Uncomment to display result.
    _OL_Close($oOutlook)
EndFunc   ;==>Listes_mails

Console output:

Listes_mails()
Size of array: Ubound($listofmailInbox):272||5
!! Next request !!
Size of array: Ubound($listofmailInbox):1||5

Outlook Ex UDF : '?do=embed' frameborder='0' data-embedContent>>

 

Here it is, if you can confirm i'm not doing anything wrong ?

Thanks.

Nicolas.

OutlookEx Problem example.au3

Edited by satanico64

Share this post


Link to post
Share on other sites



Date/Time conversion isn't easy :ermm:

This works for me:

#include <OutlookEX.au3>
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

Global $aItems = _OL_ItemFind($oOutlook, "*\Posteingang", $olMail, "[ReceivedTime]>'02/01/2014 10:00' And [ReceivedTime]<'07/01/2014 16:59'", "", "", "Subject,ReceivedTime")
If IsArray($aItems) Then
    _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails")
Else
    MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended)
EndIf

_OL_Close($oOutlook)

Replace "*Posteingang" with the name of your Inbox.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks for your answer.

In fact it does works with:

"[ReceivedTime]>'07/01/2014 10:00' And [ReceivedTime]<'09/01/2014 16:59'",

But not with

"[ReceivedTime]>'2014-01-07 10:00' And [ReceivedTime]<'2014-01-09 16:59'",

In this last format, i said again that it works with others dates..

But i just change my date format, all is ok.

About your answer, i didn't succeed  with _OL_ItemFind($oOutlook, "<mymailbox>".

But ok with _OL_ItemFind($oOutlook, $Folder[1] ....

and $Folder = _OL_FolderAccess($oOutlook, "", $olFolderInbox)

So thanks for your answer, and for <OutlookEX.au3>

Nice to read you from France.

Nicolas.

Share this post


Link to post
Share on other sites

On some time formats Outlook seems to guess what is the day and what is the month portion of the specified date.

If any value is > 12 then it has to be the day. if both values are < 12 then Outlook seems to make some incorrect assumtions.

Unfortunately I haven't found a document that properly describes how it works.

"<mymailbox>" works here. For you I assume it should be "*arrivee" (or something similar because my translation might be wrong).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - 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
Sign in to follow this  
Followers 0