Monday, November 1, 2021

Finding an item by its unique entry in outlook using Python

 import sys, win32com.client as client, datetime
import datetime,time
# Connect with MS Outlook - must be open.
outlook=client.Dispatch("Outlook.Application")

d = (datetime.date.today() - datetime.timedelta (days=7)).strftime("%d-%m-%y")
print(d)
#olFolder = outlook.GetNamespace("MAPI").Folders("allsourav@hotmail.com").Folders("Sent Items")
#itmemail = outlook.Createitem(0)
#messages = olFolder.Items
ns = outlook.GetNamespace("MAPI")
olFolder = ns.Folders("allsourav@hotmail.com").Folders("Sent Items")

myStoreID = olFolder.StoreID
myEntryID = "00000000252E983297E98F47B95403F4214B120D0700F0072D28E9944441ACCC552F18B27F6A0000000001090000F0072D28E9944441ACCC552F18B27F6A00038DE5ED3E0000"
msg = ns.GetItemFromID(myEntryID, myStoreID)

#Debug.Print foundmail.Subject, foundmail.SenderName, foundmail.ReceivedTime


print (msg.Subject,msg.SentOn.strftime("%d-%m-%y"),msg.SenderName)



No comments:

Post a Comment