Sorry If the title sounds confusing I will try my best to explain here, I m trying to scan new emails from the provided timestamp without using DateTime.DateTime.now()
for example my provided timestamp is date1 = "2022-02-05 04:03:17.690370+00:00
I want to run code for all the emails that came after this timestamp till the latest something like operator.. greater than date1.
I can use datetime_received_range=(date1, date2 ##date2 being datetime.now()) but I want to use another method.
date1 = datetime.datetime(2022, 2, 4, 20, 53, 15, tzinfo=tzutc()) ##example stored timestamp
date2 = datetime.datetime(2022, 2, 5, 4, 3, 17, 690370, tzinfo=tzutc()) ##example current timestamp
query = Q(subject='Media_Core Process')
recent_emails = account.inbox.filter(~query, datetime_received__range=(
date1,
date2
))
for item in recent_emails:
print(item.subject, item.sender, item.datetime_received)
If you want to do a greater-than filter, use __gt
or __gte
(> and >=, respectively) instead of __range
.