Planning: Will this work in PS?

Hi all

Obligatory Warning: I’m new to PowerShell, and programming in general.

I’m attempting to automate a process in work, and trying to ‘plan’ it first and so, part of what I’m trying to understand first are the steps required in each stage of the process, and naturally, if PS is the appropriate tool for it.

With regards to my script, in a nutshell, I’d like it to:

  1. check an Outlook folder on a regular basis (i.e. hourly)
  2. for any emails found, I want to extract 2/3 items of information
  3. I then want the extracted data to be sorted and split so that it can be emailed to different people (who it is emailed to is dependent on a piece of the extracted data (i.e. a process name))
  4. I then want the original email marked as ‘read’ and moved to another folder within Outlook

What I would like to know is:

  • Is this all possible within PowerShell?

  • In order to read/parse the emails, will I first need to save them all as a text file somewhere or is that unnecessary?

  • Do I need to take into account ‘access’ i.e. how does the script access my emails?

  • Broadly speaking, is this a “good” approach or am I missing something?

Thanks all
Carl

Is this all possible within PowerShell?

The steps are all possible but you will need to use COM objects to work with Outlook.

In order to read/parse the emails, will I first need to save them all as a text file somewhere or is that unnecessary?

Should not be necessary but it might make parsing the messages easier.

Do I need to take into account ‘access’ i.e. how does the script access my emails?

Not if you’re running it on the same machine, with the same account as you run Outlook.

Broadly speaking, is this a “good” approach or am I missing something?

Depends on your options. It’s certainly doable if all you have is Outlook and your e-mail account. But there are others options, such as Power Automate.

Managing an Outlook Mailbox with PowerShell

Outlook Object Model

1 Like