1

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

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("username@domain.com");

    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 有问题?有没有办法解决这个问题?任何帮助将不胜感激。

4

2 回答 2

2

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

于 2012-08-23T16:46:38.137 回答
0

你试过了吗;

appointment.Delete(DeleteMode.SoftDelete,SendCancellationsMode.SendToAllAndSaveCopy);
于 2012-06-22T08:54:57.987 回答