

You will need to pass the 5 function by way of cmd line argument and parse them programatically to read them into the main funtion call, is illustrated below.

proc - Name of the process being run "olatt" is save attachments only, "olbody" will save the text found in the body of the emails as a.olprocessedfolder - the name of the subfolder you wish you move these sucessfully processed e-mails to (must be a uniquely named folder!).olreadfolder - the name of the outlook folder which has the e-mails you wish to process (must be a uniquely named folder!).filefmt - the file format you would only like to save.outdest - the path to the folder you wish to save the attachments or email bodies.format( mail_counter) if mail_counter > 0 else 'No emails processed' Prerequisitesĭef runOlScript( outdest, filefmt, olreadfolder, olprocessedfolder, guiEntry, proc): It works like a dream and here's how to get started. It was tough to get it to work, but once you figure it out, it works without any of the funky hit-and-miss randomness anyone who's ever used VBA will have experienced. It is possible to use the same Outlook objects in python by way of a very poorly documented library called win32com. Task Scheduler is my method of choice to automate this functionality.

This is impossible to trigger via an e-mail event as Microsoft removed the ability to trigger a script on the back of one mid 2018. The VBA method which will require you to write this code in the VBE within Outlook. This is often the first question I'm asked when I tell people I can help them automate their most menial tasks. "Can you automate the saving down of attachments from a daily file I receive from x?" The below script can be called from the command line or can be embedded in another program so it is easy to schedule using a task scheduler (or crontab) as well as triggering manual runs as an embedded functionality in another program.
