I'm trying to write a script in Python to read all the subject headers, in a range date... but it doesn't work!
I have tried different solution to read emails in this range but I could not find a better option than restrict, I also tried to use [LastModificationTime]
DATA_RANGE_EMAIL = "[SentOn] > '10/01/2019 00:01 AM' AND [SentOn] < '10/10/2019 08:00 AM'"
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
utente = outlook.Folders("myaccount@myemail.com")
inbox = utente.folders("Inbox")
CRQ = inbox.folders("CRQ")
messages = CRQ.Items.restrict(DATA_RANGE_EMAIL)
message = messages.GetFirst ()
while message:
sub = message.subject.encode("utf-8")
print(sub)
message_IN = messages.GetNext ()
Now the script read ALL the email, and not just the email in that range... What am I doing wrong?
Thank you to everyone who gives me some advice!