Count the unread emails in exchange for each user

Posted by Luis on Stack Overflow See other posts from Stack Overflow or by Luis
Published on 2010-05-04T17:02:17Z Indexed on 2010/05/04 17:08 UTC
Read the original article Hit count: 250

Filed under:
|

Hi, i want to count the unread emails in exchange with c# i all conected to the exchange, and get all users and the corresponding email.

for the connection i have ..

    RunspaceConfiguration rsConfig = RunspaceConfiguration.Create();
                PSSnapInException snapInException = null;
                PSSnapInInfo info = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapInException);
                Runspace myRunSpace = RunspaceFactory.CreateRunspace(rsConfig);
                myRunSpace.Open();

                Pipeline pipeline = myRunSpace.CreatePipeline();
                Command myCommand = new Command("Get-Mailbox");

                pipeline.Commands.Add(myCommand);

                Collection<PSObject> commandResults = pipeline.Invoke();

                // Ok, now we've got a bunch of mailboxes, cycle through them
                foreach (PSObject mailbox in commandResults)
                {
                    //define which properties to get
                    foreach (String propName in new string[] { "Name", "EmailAddresses", "Database", "OrganizationalUnit", "UserPrincipalName" })
                    {
                        //grab the specified property of this mailbox
                        Object objValue = mailbox.Properties[propName].Value;
.......

© Stack Overflow or respective owner

Related posts about c#

Related posts about exchange