Outlook VSTO加载项:在删除期间迭代定期会议的异常(项目添加到垃圾文件夹)会引发COMException
My Outlook加载项向每个AppointItem添加信息,如果AppointItem被删除,则应删除这些信息(用户在日历中单击AppointItem上的delete) 为此,我使用以下事件处理。启动时,我将附加到垃圾箱文件夹: [……] [……] 当用户点击约会系列上的Delete并选择“整个系列”时,将调用Item_Delete_Add: [……] [……] 访问exception.AppointItem时,会引发以下COMException: 德语的异常描述可以解释为:您已经更改了本系列的一个元素。这个实例已经不可用了。关闭所有元素,然后重试 因此,问题归结为:我如何处理约会序列的删除,以便能够单独处理序列中的每个异常(即删除存储在该异常中的数据)。找到了解决方案 您只需通过修改上述代码来检查异常是否已被删除: [……] [……] 至少这避免了例外情况Outlook VSTO加载项:在删除期间迭代定期会议的异常(项目添加到垃圾文件夹)会引发COMException,vsto,outlook-addin,Vsto,Outlook Addin,My Outlook加载项向每个AppointItem添加信息,如果AppointItem被删除,则应删除这些信息(用户在日历中单击AppointItem上的delete) 为此,我使用以下事件处理。启动时,我将附加到垃圾箱文件夹: [……] [……] 当用户点击约会系列上的Delete并选择“整个系列”时,将调用Item_Delete_Add: [……] [……] 访问exception.AppointItem时,会引发以下COMException: 德语的异常描述可以解释为:您已经更改了本
Outlook.MAPIFolder trashFolder =
currentExplorer.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
_DeletedItems = trashFolder.Items;
_DeletedItems.ItemAdd += Item_Delete_Add;
if (myAppointment.RecurrenceState == Outlook.OlRecurrenceState.olApptMaster)
{
DialogResult dialogResult = MessageBox.Show(Resources.Resources.DeleteAllAgreeDoMeetingsInSeries, Resources.Resources.AlsoDeleteAgreeDoMeeting_DialogTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
Outlook.RecurrencePattern pattern = myAppointment.GetRecurrencePattern();
foreach (Outlook.Exception exception in pattern.Exceptions)
{
if (!deleteAppointment(exception.AppointmentItem,true))
{
wasSuccessfull = false;
}
}
}
} else
if (myAppointment.RecurrenceState == Outlook.OlRecurrenceState.olApptMaster)
{
DialogResult dialogResult = MessageBox.Show(Resources.Resources.DeleteAllAgreeDoMeetingsInSeries, Resources.Resources.AlsoDeleteAgreeDoMeeting_DialogTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
Outlook.RecurrencePattern pattern = myAppointment.GetRecurrencePattern();
foreach (Outlook.Exception exception in pattern.Exceptions)
{
if (!exception.Deleted)
{
if (!deleteAppointment(exception.AppointmentItem, true))
{
wasSuccessfull = false;
}
}
}
}
} else