Mar-05-2020, 06:00 PM
OS: Windows 10
Python 3.6
I'm working on piecing together some base code for me to search through a folder in Outlook to locate a specific message for a specific date. I'm fairly happy with my progress but I'm a bit frustrated with my date/time output.
What I'm getting...
Some help getting this to the format I'm looking for would be greatly appreciated!
here is my code...
Python 3.6
I'm working on piecing together some base code for me to search through a folder in Outlook to locate a specific message for a specific date. I'm fairly happy with my progress but I'm a bit frustrated with my date/time output.
What I'm getting...
Output:Sent: (datetime.date(2020, 3, 5), datetime.time(8, 8, 16))
Received: ('2020-03-05', '08:08:16.765000')
When what I want to see is...Output:Sent: 2020-03-05 08:08:16
Received: 2020-03-05 08:08:16
This example message was sent from myself to myself so I ended up with the same date/time value.Some help getting this to the format I'm looking for would be greatly appreciated!
here is my code...
import win32com.client import win32com import os outlook = win32com.client.Dispatch("outlook.Application").GetNameSpace("MAPI") inbox=outlook.GetDefaultFolder(6) messages = inbox.items for message in messages: receipt = message.ReceivedTime.date() if str(receipt) == "2020-03-05": subject = message.Subject if str(subject) == "Test Message": subject=message.Subject datesent=message.senton.date() timesent=message.senton.time() sent = (datesent, timesent) receipt = str(message.ReceivedTime.date()), str(message.ReceivedTime.time()) sender = message.Sender print ("Received:", receipt) print ("Subject:", subject) print ("Sender:", sender) print ("Sent:", sent) print ("Received:", receipt) message.Close(0)