[英]Count the unread emails in exchange for each user
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. 我想计算与C#交换的未读电子邮件,所有这些邮件都已交换,并获得所有用户和相应的电子邮件。
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;
.......
The command you want is Get-MailboxStatistics . 您想要的命令是Get-MailboxStatistics 。 You can get the Inbox_Number_Unread off the objects returned.
您可以获取Inbox_Number_Unread返回的对象。
Glen Scales posted this blog article about pulling similar information via PowerShell. Glen Scales发布了此博客文章,内容涉及通过PowerShell提取类似信息。 It should point you in the right direction.
它应该为您指明正确的方向。 It has a full script which gathers useful properties off all mailboxes.
它具有完整的脚本,可从所有邮箱中收集有用的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.