Question

I am new to Exchange and we have a requirement where we need to go thru everyones mailbox and look for emails that have been marked by a certain category and set those emails as sensitivity:private. And I have couple of questions on this one:

  • Not sure which one is the way to achieve this, should I be using Exchange Management Console - PowerShell script OR Exchange Web Services?
  • does anyone have a snippet of searching emails by category and manipulating/editing the email sensitivity to Private?

Thanks Steve

Was it helpful?

Solution

You can use AQS in combination with Exchange Web Services to query by category.

  ItemView iv = new ItemView(1000);
  String AQS = "System.Category:red OR System.Category:green";
  FindItemsResults<Item> fiItems = null;
  do
  {
    fiItems = service.FindItems(WellKnownFolderName.Calendar, AQS, iv);
    foreach (Item itItem in fiItems.Items) {
      Console.WriteLine(itItem.Subject);
    }
    iv.Offset += fiItems.Items.Count;
  } while (fiItems.MoreAvailable == true);

See also:

To set the Sensitivity, use the item.Sensitivity property and then save the item:

  item.Sensitivity = Sensitivity.Private;
  item.Save();

See also:

Since EWS is just a Managed library, you can also call these methods from Powershell. I'm not sure if there are existing Powershell cmdlets available to do the same type of manipulations, but this would work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top