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

Welcome Forums General PowerShell Q&A How to read the messages from an Office 365 mailbox / archive using Powershell

This topic contains 3 replies, has 3 voices, and was last updated by

3 years, 3 months ago.

  • Author
  • #19272

    Points: 0
    Rank: Member

    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

  • #19314

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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, which uses PowerShell *and Outlook* to access mailbox contents.

  • #19342

    Points: 0
    Rank: Member

    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.


  • #31579

    Points: 0
    Rank: Member

    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,

    Reading emails from Office365 account using PowerShell

The topic ‘How to read the messages from an Office 365 mailbox / archive using Powershell’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort