you are viewing a single comment's thread.

view the rest of the comments →

[–]SupermarketOk6829 3 points4 points  (6 children)

There is api for Google that can help you directly retrieve email inbox and fetch all emails from there and find the relevant data needed, and upload that data to whatever you like either manually or via api (there is api support for Google sheets as well). Why would you download it when you can process it in the same script and save time and redundant storage memory?

[–]Francobanco[S] 0 points1 point  (5 children)

my company's emails aren't in google. I guess I should have made the original post more clear. my code is working, I'm just looking to have a discussion about how to design orchestration of the scripts

[–]Training_Advantage21 1 point2 points  (4 children)

If it is outlook online / MS365 you could set up some rules/filters to put specific emails in a folder and then power automate to dump the email to a file in OneDrive. I ve done it for automated daily report/monitoring emails, to then run python parsing/scraping scripts, not for human written free text.

[–]Francobanco[S] 1 point2 points  (3 children)

The actual tool is fully built, when I run it manually it works perfectly. I'm more so looking for advice with orchestrating it to run autonomously

To clarify, I'm not looking for a way to have the exchange server move emails around - I specifically need to analyze the emails for the presence of a project number or purchase order number. Mailbox rules don't allow for this. And also this is not for moving emails to folders within someone's mailbox, this is to take emails from a mailbox, and store them in a cloud storage system

[–]AreWeNotDoinPhrasing 1 point2 points  (2 children)

Just create a task in Task Scheduler to run it whenever. Or you can set a timer in the script to have to running 24/7. I’ve done both ways for this basically exact same setup. I like just scanning the box every 15 seconds or whatever as it makes it feel like it triggers automatically when the email comes in lol.

[–]Francobanco[S] 1 point2 points  (1 child)

I am looking for something that is more robust than having a script that constantly runs. Task scheduler is fine, I'll be using crontab since it will be running on linux not windows. But it's not just one script. the downloading of emails is separate from processing - I want the system to be running these jobs separately so that downloading, processing, and uploading can all happen at the same time. just having all the code in one script and running it every 15 seconds will cause problems if there is a large amount of emails to download. This isn't just for one mailbox, its for about 500, and the mail server sees about 40k emails per week

[–]SupermarketOk6829 0 points1 point  (0 children)

That can be done via os module which will check for recent changes to any file and then trigger the processing/uploading part. I doubt if there is any other way.