2012-06-21 25 views
1

我正在开发一个将交换日历同步到另一个日历的应用程序。为了保留两个日历中的约会之间的映射,我在交换约会上放置了扩展属性。一切工作正常,直到我试图从定期约会的事件中删除扩展属性。当我尝试这样做,我得到的错误:RemoveExtendedProperty在定期约会中使用时引发错误

The delete action is not supported for this property. 

下面是一个代码片段演示了错误:

public void ExchangeTest() 
{ 
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1) 
    { 
     Credentials = new NetworkCredential("username", "password", "domain") 
    }; 
    service.AutodiscoverUrl("[email protected]"); 

    Appointment appt = new Appointment(service) 
    { 
     Recurrence = new Recurrence.DailyPattern(DateTime.Now, 2) { NumberOfOccurrences = 3}, 
     Start = DateTime.Now, 
     End = DateTime.Now.AddHours(2), 
     Subject = "Test Appointment" 
    }; 
    NameResolutionCollection resolutionCollection = service.ResolveName("username", ResolveNameSearchLocation.DirectoryOnly, false); 
    string mailboxAddress = resolutionCollection.First().Mailbox.Address; 
    FolderId folderId = new FolderId(WellKnownFolderName.Calendar, mailboxAddress); 
    appt.Save(folderId); 
    PropertySet properties = new PropertySet(AppointmentSchema.ICalUid); 
    appt.Load(properties); 

    CalendarView view = new CalendarView(DateTime.Today, DateTime.Today.AddDays(8)){PropertySet = properties}; 

    IEnumerable<Appointment> occurrences = service.FindAppointments(folderId, view) 
     .Where(a => a.ICalUid == appt.ICalUid); 

    ExtendedPropertyDefinition definition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "TestProperty", MapiPropertyType.String); 
    Appointment firstOccurrence = occurrences.First(); 
    firstOccurrence.SetExtendedProperty(definition, "test"); 
    firstOccurrence.Update(ConflictResolutionMode.AutoResolve); 

    //The error occurs on the next line. 
    firstOccurrence.RemoveExtendedProperty(definition); 
    firstOccurrence.Update(ConflictResolutionMode.AutoResolve); 

    //clean up 
    appt.Delete(DeleteMode.HardDelete); 
} 

看来,错误只是抛出一个Exchange 2007服务器(这在2010年工作)。我做错了什么,或者这是Exchange的问题?有没有办法解决这个问题?任何帮助将不胜感激。

回答

1

我结束了不使用RemoveExtendedProperty功能。相反,我通过再次设置属性来解决它,但将其设置为空白区域。然后我处理了代码中的空白区域。这似乎是Exchange或托管API的问题。

0

你试过了吗?

appointment.Delete(DeleteMode.SoftDelete,SendCancellationsMode.SendToAllAndSaveCopy); 
+0

我不想删除约会。我想从约会中删除扩展的属性。 –

相关问题