Exchange Web服务。预约灵敏度

时间:2014-05-28 09:59:34

标签: exchangewebservices

我可以阅读约会对其相应财产的敏感度。

问题是,它只返回“正常”或“私人”。 但实际上,约会也可以在“属性”窗口中设置为“机密/个人”。但无论我在那里设置什么,约会总是“正常”,除非我将其设置为私人。

confidential - > appointment.Sensitivity = Sensitivity.Normal ???

这就是我阅读约会的方式:

var smtpAddress ="mailboxesemail"
var calendarItems = new List<CalendarItem>();
var service = service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Url = new Uri("https://EWSServerName/EWS/Exchange.asmx");
service.Credentials = new WebCredentials(System.Net.CredentialCache.DefaultCredentials);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "RightToImpersonateaccount");
var cv = new CalendarView(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1));
cv.Traversal = ItemTraversal.Shallow;
var findresults = service.FindAppointments(WellKnownFolderName.Calendar, cv)
var items = findresults.Cast<Item>().ToList();
var propertiesToLoad = new PropertySet(BasePropertySet.FirstClassProperties) { RequestedBodyType = BodyType.Text };
service.LoadPropertiesForItems(items, propertiesToLoad)
foreach (Appointment appointment in items)
{
   var item = new CalendarItem();//Own class
  item.Sensitivity = appointment.Sensitivity.ToString(); **<-- This is always normal, except when set to Private**
}

必须有一种方法来阅读它。因为在Outlook上正确显示了灵敏度。

帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

作为一种变通方法,您可以使用扩展属性,而不是强类型属性,它应该反映属性值。例如

        ExtendedPropertyDefinition PR_SENSITIVITY = new ExtendedPropertyDefinition(0x0036, MapiPropertyType.Integer);
        var propertiesToLoad = new PropertySet(BasePropertySet.FirstClassProperties) { RequestedBodyType = Microsoft.Exchange.WebServices.Data.BodyType.Text };
        propertiesToLoad.Add(PR_SENSITIVITY);
        service.LoadPropertiesForItems(items, propertiesToLoad);
        foreach (Appointment aptval in items)
        {
            Int32 SensVal = 0;
            if (aptval.TryGetProperty(PR_SENSITIVITY, out SensVal))
            {
                switch(SensVal){
                    case 0 : Console.WriteLine("SENSITIVITY_NONE");
                        break;
                    case 1 : Console.WriteLine("SENSITIVITY_PERSONAL");
                        break;
                    case 2 : Console.WriteLine("SENSITIVITY_PRIVATE");
                        break;
                    case 3 : Console.WriteLine("SENSITIVITY_COMPANY_CONFIDENTIAL");
                        break;
                }
            }               
        }

干杯 格伦