How to find the count or the oldest mail in the mailbox, hosted on Exchange online RRS feed

  • Question

  • Hello Team,

    Can you refer me to some samples or code hints to find either the count of all mails or the oldest mail in the mailbox? The mailbox is hosted on Microsoft Exchange online.

    I tried the following with success, but this requires Exchange Admin access to execute:

    Get-MailboxFolderStatistics mymailbox-IncludeOldestAndNewestItems -FolderScope inbox | Select Name, Folderpath, ItemsInFolder, FolderSize, OldestItemReceivedDate

    Therefore can you confirm if there are alternative ways to fetch the information of the oldest email. Or the admin access is must to fetch the information. I have the credentials the mailbox.

    Kindly help.

    Friday, April 5, 2019 11:53 AM

All replies

  • Hi,

    Thanks for your question.

    You need to use "Sort-Object" to sort the mails and select the oldest mail. For example:

    Get-MailboxFolderStatistics mymailbox-IncludeOldestAndNewestItems -FolderScope inbox | Where OldestItemReceivedDate -ne $null | 
        Sort OldestItemReceivedDate | Select -First 1 -property Name, Folderpath, ItemsInFolder, FolderSize, OldestItemReceivedDate

    About PowerShell permission issue, if your account has the permission to fetch the info, you can use your account to run the command. If your account doesn't have access permission to get it, you need to run with the administrator.

    The permissions that PowerShell has to depend on the permissions of the running command account.

    Best regards,


    Just do it.

    • Proposed as answer by ComputerScott Monday, April 8, 2019 10:36 PM
    Monday, April 8, 2019 2:09 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Just do it.

    Wednesday, April 10, 2019 9:08 AM
  • Thanks for the help.

    I am working with internal Exchange team to confirm this.

    What permission is required to fetch the info? I am unable to execute the command for the "mymailbox"; i have the correct credentials and and also opened the PowerShell using the mymailbox password.

    Secondly, is there any other way to find the oldest email on the mailbox hosted on Exchange Online? This will help avoid the additional permission that will be required.

    Wednesday, April 10, 2019 9:47 AM