在Outlook加载项上保存异常
本文关键字:保存 异常 加载项 Outlook | 更新日期: 2023-09-27 17:59:06
我正在尝试以编程方式更改重复周期的项目(并进行例外处理)。
该项目是Outlook 2010加载项。
我尝试了以下代码,但在保存了几次后,代码在calitm.Save()
命令处退出
extracted ="somelocation"
//that's a fancy way to iterate on a list of appointment items
for (int i = 0; i < filterAppointmentsToChangeLocation.RecordCount; i++)
{
int selrow = 1
var calitm = filterAppointmentsToChangeLocation.data[selrow].GetOlAppointment();
//this returns an appointmentitem that is associated with a form
//that contains the location property
calitm.UserProperties["location"].Value = extracted;
calitm.Save();
Marshal.ReleaseComObject(calitm);
}
你有什么建议吗?感谢您的时间。。。
如果您的代码存在,则表示在调用Save方法的过程中出现了崩溃。
实际上,您需要尝试/捕获错误代码,以便保存/重新抛出异常
for (int i = 0; i < filterAppointmentsToChangeLocation.RecordCount; i++)
{
int selrow = 1
var calitm = filterAppointmentsToChangeLocation.data[selrow].GetOlAppointment();
try
{
calitm.UserProperties["location"].Value = extracted;
calitm.Save();
}
catch (Exception e)
{
// save, output or retrhow your exception.
System.IO.File.WriteAllText (@"C:'somepath'error.txt", e.Message);
}
Marshal.ReleaseComObject(calitm);
}