vsto创建重复异常“无法保存此项目。” [英] vsto create recurrence exception "cannot save this item."

查看:66
本文介绍了vsto创建重复异常“无法保存此项目。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


当我创建一个重复异常时,我在保存新的异常实例时遇到异常。以下是我写的代码。我按照
这里所示的代码进行操作。不确定我缺少什么,请帮忙。

 if(myInstance!= null)
{
myInstance.Subject = exAppoinment.Title;
myInstance.Save();

Outlook.RecurrencePattern newPattern = oNewItem.GetRecurrencePattern();
var cnt = newPattern.Exceptions.Count;
Outlook.Exception myException =(newPattern.Exceptions.Count> 0?newPattern.Exceptions [newPattern.Exceptions.Count]:
newPattern.Exceptions [1]);
if(myException!= null)
{
Outlook.AppointmentItem myNewInstance =
myException.AppointmentItem;
myNewInstance.Start = stdt;
myNewInstance.End = endt;
myNewInstance.Body = exAppoinment.Body;
myNewInstance.UserProperties.Add(" SCSID",Outlook.OlUserPropertyType.olInteger,false).Value = exAppoinment.SmartCalenderId;
myNewInstance.Save(); //这是我获得EXCEPTION

ReleaseComObject(myNewInstance);
myNewInstance = null;
}

oNewItem.Save();
ReleaseComObject(myException);
myException = null;

ReleaseComObject(newPattern);
newPattern = null;

ReleaseComObject(myInstance);
myInstance = null;
}

解决方案

Hello Pradeep,


与大多数其他Microsoft Outlook对象不同,  例外   对象是一个只读对象。这意味着您无法创建  例外   对象
但是,当 
AppointmentItem   已更改。例如,如果您更改  开始   属性
of一个 
AppointmentItem ,您已创建  例外     AppointmentItem.RecurrencePattern.Exceptions


尝试使用
GetOccurrence
 来自RecurrencePattern类的方法。


Hi,

When I am creating a recurrence exception, I am getting an exception when I am saving the new instance of exception. Following is the code I have written. I am following the code illustrated at Here. Not sure what I am missing, please help.

if (myInstance != null)
{
	myInstance.Subject = exAppoinment.Title;
	myInstance.Save();

	Outlook.RecurrencePattern newPattern = oNewItem.GetRecurrencePattern();
	var cnt = newPattern.Exceptions.Count;
	Outlook.Exception myException = (newPattern.Exceptions.Count > 0 ? newPattern.Exceptions[newPattern.Exceptions.Count] :
		 newPattern.Exceptions[1]);
	if (myException != null)
	{
		Outlook.AppointmentItem myNewInstance =
			myException.AppointmentItem;
		myNewInstance.Start = stdt;
		myNewInstance.End = endt;
		myNewInstance.Body = exAppoinment.Body;
		myNewInstance.UserProperties.Add("SCSID", Outlook.OlUserPropertyType.olInteger, false).Value = exAppoinment.SmartCalenderId;
		myNewInstance.Save(); //HERE I AM GETTING THE EXCEPTION

		ReleaseComObject(myNewInstance);
		myNewInstance = null;
	}

	oNewItem.Save();
	ReleaseComObject(myException);
	myException = null;

	ReleaseComObject(newPattern);
	newPattern = null;

	ReleaseComObject(myInstance);
	myInstance = null;
}

解决方案

Hello Pradeep,

Unlike most of the other Microsoft Outlook objects, the Exception object is a read-only object. This means that you cannot create an Exception object but, rather, the object is created when a property of an AppointmentItem is altered. For example, if you change the Start property of one AppointmentItem, you have created an Exception in AppointmentItem.RecurrencePattern.Exceptions.

Try to use the GetOccurrence method of the RecurrencePattern class instead.


这篇关于vsto创建重复异常“无法保存此项目。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆