How to read the messages from an Office 365 mailbox / archive using Powershell

I’m attempting to read the messages from my mailbox using PowerShell 4.

I can open my mailbox, and I can enumerate the folders.

I can’t seem to find a way to read messages from the folders, and wonder if anyone has some code they would like to recommend for doing so with Office 365 latest as of this date.

I would like to be able to read messages from my inbox as well as my online archive (which I have not found a way to access as of yet), enumerate them, and be able to output their content (subject, from addresses, message, etc)

-thanks in advance

As far as I’m aware (and I could be wrong), the Exchange commands don’t include anything for reading content from mailbox items. That would include O365.

However, O365 supports the IMAP protocol. You could certainly use that to access the contents of a mailbox, but there are no native command sfor doing so. /n software’s PowerCmdlets may offer an IMAP option.

You might also look at Tooling with PowerShell: Keep it simple | Pluralsight, which uses PowerShell and Outlook to access mailbox contents.

Upon changing my approach from remoting to the Office 365 server to looking at Exchange functionality, I discovered the EWS Dll.

It appears that one can use that and obtain just about whatever one wants via the web. I’m sure it is throttled, but should work.

Some links I’ve found so far:

Reading headers… this one is just a few inches from what I need, because it already opens the item. Just a matter of looking at the $item.body


Get messages (use with caution – don’t know the site yet)

The trick was discovering that Exchange Office 365 could be accessed with the Microsoft.Exchange.Webservices dll, and then
binging for : “powershell” …

I’ll remember that algorithm in the future, since I’m a C#/>net developer. If searches for what you want to do like “powershell read email” don’t turn up anything, look up how one would do it in C#, and find the object name, and search for that.

I appreciate this community and all your help.

Powershell on.


Here is some PowerShell code to read emails from O365 with only the .dll file from the EWS required.

Includes reading the body of the email,