Here I am trying to extract one particular email data which is present in sent items folder in outlook? but I am unable to find any method to give such condition , like if this particular email present in sent item folder then extract subject, date & time.
import win32com.client
from win32com.client import Dispatch
import regex as re
from datetime import datetime, timedelta
outlook = win32com.client.Dispatch('outlook.application')
mapi = outlook.GetNamespace("MAPI")
sentitem = mapi.GetDefaultFolder(5)
messages = sentitem.Items
for msg in messages:
here after I am not getting any idea. Can anyone help me to find this
You cannot use regex with the Outlook Object Model, but you can use Items.Find/FindNext
and Items.Restrict
to find the message(s).
See https://learn.microsoft.com/en-us/office/vba/api/outlook.items.restrict for the syntax and sample queries.