When I use msg.SentOn.stftime("%Y-%m-%d %H:%M:%S %Z %z %p")
I get GMT as timezone however all the message times are in IST for example an email sent at 1.30PM IST
shows 2017-09-19 13:30:51 GMT+00:00 +000
. However what I want is 2017-09-19 09:00:51 GMT+00:00 +000
. The code is as below
import datetime, win32com.client as win32
outlook = win32.Dispatch("Outlook.Application").GetNamespace("MAPI")
excel = win32.gencache.EnsureDispatch("Excel.Application")
inbox = outlook.GetDefaultFolder(6)
for msg in inbox.Items:
print(msg.SentOn.strftime("%Y-%m-%d %H:%M:%S %Z %z %p"), msg.Subject)