Script for reading mail

Hi, I want to develop a script that reads the mapi mailbox of a certain user, saves all attachments of the mails from which the subject contains a certain string. Save folder should be dependent on certain information in the body of the mail. Any suggestions to get me started are welcome.

I googled it for you and found some sites you may find helpful as a starting point :wink:

https://social.technet.microsoft.com/Forums/windowsserver/en-US/11218cf2-eb24-4110-967f-b29234064501/how-do-i-save-outlook-attachments-using-powershell?forum=winserverpowershell

https://www.example-code.com/powershell/imap_downloadAttachment.asp

1 Like

Thnx but my main challenge is to be able to specify the username and password somewhere. The examples you provided seem to use my own mailbox, that is not wanted.

The StackOverflow thread has a link explaining how to use EWS to accomplish this task.

Another idea would be to run the PowerShell session as the desired user or to use the task scheduler to impersonate the desired user and run the script in its context.