Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29758

How to write a python script to read all subject headers of my Outlook... is it in a date range?

$
0
0

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!


Viewing all articles
Browse latest Browse all 29758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>