How to count number of attachments in a mailbox? RRS feed

  • Question

  • Hi everybody,

    I want to count the number of attachments in mailbox. Kindly help me.

    Thanks & regards,

    Talib Hussain

    • Edited by talib2608 Wednesday, January 21, 2015 5:49 AM
    Wednesday, January 21, 2015 5:44 AM

All replies

  • You can do that by enumerating every message in every folder that has attachment using EWS and then count them one by one. Its a time consuming process see for a sample script


    Thursday, January 22, 2015 2:55 AM
  • Hi Glen,

    I saw that script. It there some other way?

    Friday, February 13, 2015 1:54 PM
  • No you might want take a look at Get-MailboxStatistics which list all the information that is tracked at the Mailbox level by exchange for administrators to consume easily.


    Sunday, February 15, 2015 10:17 PM
  • Hi Glen,

    Get-MailboxStatistics & Get-MailboxFolderStatistics are helpful regarding items, not attachments. And that too, both commands give wrong information. Actual data present in a mailbox is different, Get-MailboxStatistics give different results & Get-MailboxFolderStatistics give different results.

    Wednesday, February 18, 2015 10:11 AM
  • Hi Talib,

    in Your case i think you will need to combine Get-mailboxfolderstatistic and search-mailbox.

    Is Your goal to only search Your mailbox on the Whole organization?

    If only on Your mailbox you can use Power Query in Excel to filter out only Messages With attachment.

    You could also use built in search folder in Outlook to only list mails With attachment.Again this Works only on Your private mailbox and not for Whole organization.

    Could be some great minds out there that could create a script for Your needs.

    In Our case we used this command to search for all mailboxes with attachment greater than 25mb and export them to pst file (individual pst files)

    $MBX = Get-Mailbox
    –resultsize unlimited | foreach {New-MailboxExportRequest -Mailbox $_.Identity -ContentFilter {Size -gt '25MB'} -FilePath ('\\Server\Share\path\ ‘ + $_.Alias + '(' + $_.DisplayName + ').PST')}

    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you. Thank you! Off2work

    Wednesday, February 18, 2015 12:22 PM
  • Hi Off2work,

    Creating profile of every user is not a feasible solution. Also, the command that you wrote (ContentFilter parameter) is for whole message and not only attachment. And is the script is for one mailbox, then it will not be difficult to expand it to all mailboxes. Whenever I will be free, I will only create this script and post it on WWW.

    Wednesday, February 25, 2015 2:45 PM