locked
Getting Unread item count for a single user RRS feed

  • Question

  • I want to know if there is a way to easily get the unread mail count for a specific user. I was unable to find it through the get-mailboxfolderstatistics or any other management shell commands. MFCMAPI does not pull this information for an account unless its added to the local outlook profile. I guess I can take full permission to the account and add it to outlook and figure out the unread message count in folders but that seems rather clumsy. Isn't there a way to pull this information on the Server side?
    I want to believe
    Friday, December 9, 2011 5:01 PM

Answers

  • There is nothing to it, rather than looping for all users, I just used the script for one user.

    1. so go to the blog: http://gsexdev.blogspot.com/2008/11/find-unused-mailbox-powershell-gui.html
    2. Download the ewsutil.zip file and extract all contents to C:\Temp (http://msgdev.mvps.org/exdevblog/ewsutil.zip)
    3. Download the provided code for the scripts
    4. In the Unreadgui.zip you will find a script file unreadreport_Simple.ps1 Open and edit the code to match this, or you can copy paste this code in the file and run the script. Please remember to enter the user for which you want the unread count:

     

    [void][Reflection.Assembly]::LoadFile("C:\temp\EWSUtil.dll")
    
    
    $mbcombCollection = @()
    
    $specificuser = get-mailbox -identity <INSERT USER ALIAS HERE>
    
        $mbcomb = "" | select DisplayName,EmailAddress,Unread
        $mbcomb.DisplayName = $specificuser.DisplayName.ToString()
        $mbcomb.EmailAddress = $specificuser.WindowsEmailAddress.ToString()
        $mbMailboxEmail = $specificuser.WindowsEmailAddress.ToString()
        "Mailbox : " + $mbMailboxEmail
        $ewc = new-object EWSUtil.EWSConnection($mbMailboxEmail,$false, $null,$null,$null,$null)
        $dTypeFld = new-object EWSUtil.EWS.DistinguishedFolderIdType
        $dTypeFld.Id = [EWSUtil.EWS.DistinguishedFolderIdNameType]::inbox
    
        $mbMailbox = new-object EWSUtil.EWS.EmailAddressType
        $mbMailbox.EmailAddress = $mbMailboxEmail
        $dTypeFld.Mailbox = $mbMailbox
    
        $fldarry = new-object EWSUtil.EWS.BaseFolderIdType[] 1
        $fldarry[0] = $dTypeFld
    
        $fldList = $ewc.GetFolder($fldarry)
        [EWSUtil.EWS.FolderType]$pfld = [EWSUtil.EWS.FolderType]$fldList[0];
            $mbcomb.Unread = $pfld.UnreadCount
        $mbcombCollection += $mbcomb
    
    
    $mbcombCollection
    


     

    Please remember that you will need access to the the user's account for this to work and thank Glen on his blog when you get it working!

     


    I want to believe
    • Edited by Khan Saheb Friday, December 9, 2011 6:52 PM
    • Marked as answer by Khan Saheb Friday, December 9, 2011 6:54 PM
    Friday, December 9, 2011 6:51 PM
  • Hello Khan,

    please have a look on this...

    http://gsexdev.blogspot.com/2008/11/find-unused-mailbox-powershell-gui.html


    Thanks & Regards, Kottees *** Please mark it as an answer if it really helps you.
    • Marked as answer by Khan Saheb Friday, December 9, 2011 6:09 PM
    Friday, December 9, 2011 5:33 PM

All replies

  • Hello Khan,

    please have a look on this...

    http://gsexdev.blogspot.com/2008/11/find-unused-mailbox-powershell-gui.html


    Thanks & Regards, Kottees *** Please mark it as an answer if it really helps you.
    • Marked as answer by Khan Saheb Friday, December 9, 2011 6:09 PM
    Friday, December 9, 2011 5:33 PM
  • imkottees that is certainly good but the script will run for all users (6-8K in total) I need it for just one user.
    I want to believe
    Friday, December 9, 2011 5:55 PM
  • for one user you can do like this.... but i m not sure this can be posted here... if it is wrong please delete this post who has rights..

    step 1: Give full mailbox permission to yourself for user mailbox.

    step 2: open owa like...

    https://webmail.yourdomain.com/owa/abc@domain.com

    use user email address instead of abc@domain.com

    step 3: when asking for credentials give yours

    step 4: now you can see the users mailbox, of course you can see the unread mails counts

    Note: once you open the users mailbox please turn off the reading pane.

    The same can be done by configuring outlook which tougher than owa.

    hope this helps.


    Thanks & Regards, Kottees *** Please mark it as an answer if it really helps you.
    Friday, December 9, 2011 6:06 PM
  • Nevermind, There is a simpler unread count script there. I modified it to run for only a specific user and it is working fine. Thanks
    I want to believe
    Friday, December 9, 2011 6:09 PM
  • thats great.. If you don't mind you can share with us. It will be helpful for others.


    Thanks & Regards, Kottees *** Please mark it as an answer if it really helps you.
    Friday, December 9, 2011 6:15 PM
  • There is nothing to it, rather than looping for all users, I just used the script for one user.

    1. so go to the blog: http://gsexdev.blogspot.com/2008/11/find-unused-mailbox-powershell-gui.html
    2. Download the ewsutil.zip file and extract all contents to C:\Temp (http://msgdev.mvps.org/exdevblog/ewsutil.zip)
    3. Download the provided code for the scripts
    4. In the Unreadgui.zip you will find a script file unreadreport_Simple.ps1 Open and edit the code to match this, or you can copy paste this code in the file and run the script. Please remember to enter the user for which you want the unread count:

     

    [void][Reflection.Assembly]::LoadFile("C:\temp\EWSUtil.dll")
    
    
    $mbcombCollection = @()
    
    $specificuser = get-mailbox -identity <INSERT USER ALIAS HERE>
    
        $mbcomb = "" | select DisplayName,EmailAddress,Unread
        $mbcomb.DisplayName = $specificuser.DisplayName.ToString()
        $mbcomb.EmailAddress = $specificuser.WindowsEmailAddress.ToString()
        $mbMailboxEmail = $specificuser.WindowsEmailAddress.ToString()
        "Mailbox : " + $mbMailboxEmail
        $ewc = new-object EWSUtil.EWSConnection($mbMailboxEmail,$false, $null,$null,$null,$null)
        $dTypeFld = new-object EWSUtil.EWS.DistinguishedFolderIdType
        $dTypeFld.Id = [EWSUtil.EWS.DistinguishedFolderIdNameType]::inbox
    
        $mbMailbox = new-object EWSUtil.EWS.EmailAddressType
        $mbMailbox.EmailAddress = $mbMailboxEmail
        $dTypeFld.Mailbox = $mbMailbox
    
        $fldarry = new-object EWSUtil.EWS.BaseFolderIdType[] 1
        $fldarry[0] = $dTypeFld
    
        $fldList = $ewc.GetFolder($fldarry)
        [EWSUtil.EWS.FolderType]$pfld = [EWSUtil.EWS.FolderType]$fldList[0];
            $mbcomb.Unread = $pfld.UnreadCount
        $mbcombCollection += $mbcomb
    
    
    $mbcombCollection
    


     

    Please remember that you will need access to the the user's account for this to work and thank Glen on his blog when you get it working!

     


    I want to believe
    • Edited by Khan Saheb Friday, December 9, 2011 6:52 PM
    • Marked as answer by Khan Saheb Friday, December 9, 2011 6:54 PM
    Friday, December 9, 2011 6:51 PM
  • Thank you so much.. have a great weekend:)
    Thanks & Regards, Kottees *** Please mark it as an answer if it really helps you.
    Friday, December 9, 2011 6:55 PM