I'm looking to create an automation script that checks an Outlook mailbox every 5 minutes. This script needs to identify emails with a specific subject line and pull out information about the Server and Service from the email body. Based on this information, it should determine if the server is either EC2 or on-premises. If it's EC2, I want to use AWS SSM, and if it's a private server, I'd prefer using Paramiko SSH to restart the Tomcat service. After restarting, the script should send a confirmation email back. I'd like to know the best architecture, setup, and deployment method to accomplish this on a server where heavy engines aren't feasible, while also ensuring security, idempotency, and audit logs. I have some preliminary thoughts: I can utilize win32 for accessing Outlook emails and manage connections via paramiko for SSH. Given that I only expect about 20-50 emails daily, it seems manageable with a lightweight Python approach since my manager has provided me with a server that has Python installed.
2 Answers
Do you need help with your regular expression for parsing the email body or the permissions for the SSM policy? Let me know what specific details you’re looking for!
Are you pulling emails that are already downloaded onto a client? Or do you need to query them through the Graph API?
I’m dealing with Outlook mails that are already downloaded. They don't want the Graph API method.

I’m mainly looking for the full regex to parse the body correctly.