AppointmentItem事件不会在自定义日历/文件夹中触发 [英] AppointmentItem events don't fire in custom calendar/folder

查看:101
本文介绍了AppointmentItem事件不会在自定义日历/文件夹中触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我遇到了问题我似乎无法弄清楚是什么问题,我希望有人可以帮助我或指出正确的方向。



好的,我的问题:


对于Outlook VSTO Add In我正在处理我为某些约会创建一个新的自定义日历/文件夹。

 

private static MAPIFolder GetPrimaryCalendar( )(
返回Globals.ThisAddIn.Application.ActiveExplorer()。Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
}

GetPrimaryCalendar()。Folders.Add( Resources.TimCalendarName,OlDefaultFolders.olFolderCalendar);

这一切都按预期工作。


新的日历/文件夹被称为'Tim-Calendar'。



然而,当我将某些约会移动到Tim-Calendar时,这些约会的自定义事件不要再被解雇了。


我尝试在mov之后添加事件约会:

 if(!(_ appointment.Move(timFolder)is AppointmentItem app))
{
//不相关。
返回;
}
app.BeforeDelete + = AppointmentBeforeDelete;
app.Save();

我还尝试在移动预约之前添加事件:

 _appointment.BeforeDelete + = AppointmentBeforeDelete; 
_appointment.Save();
if(!(_ appointment.Move(timFolder)是AppointmentItem app))
{
//不相关。
返回;
}
app.Save();

'_约会'是我想要移动的约会。


'timFolder'是Tim-Calendar。


当使用AppointmentItem.Move()方法时,会创建一个新的约会,我称之为'app'。


请注意,当我没有将约会移动到Tim-calendar时,我测试了事件触发。



I真的不知道我做错了什么,所以我希望有人可以帮助我。



提前致谢,


Frenk

解决方案

你好Frenk,


我可以重现你的问题。我建议你转到Outlook文件 - >反馈以提交针对此问题的反馈。


作为解决方法,下面的代码可能看起来很奇怪,但它确实适用于我。

 AppointmentItem app = _appointment.Move(timFolder); 
//访问GlobalAppointmentID属性后,事件有效。
var a = app.GlobalAppointmentID;
app.BeforeDelete + = AppointmentBeforeDelete;
app.Save();

最好的问候,


Terry


Hello everybody,

I'm stuck with a problem and I can't seem to figure out what's wrong, I hope someone here can help me or point me to the right direction.

Okay so my problem:

For an Outlook VSTO Add In I'm working on I create a new custom calendar/folder for certain Appointments.

private static MAPIFolder GetPrimaryCalendar()
{
return Globals.ThisAddIn.Application.ActiveExplorer().Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
}

GetPrimaryCalendar().Folders.Add(Resources.TimCalendarName, OlDefaultFolders.olFolderCalendar);

This is all working as intended.

The new calendar/folder is called the 'Tim-Calendar'.

However, when I move certain Appointments to the Tim-Calendar, the custom events of these Appointments don't get fired anymore.

I tried adding the event after moving the Appointment:

if (!(_appointment.Move(timFolder) is AppointmentItem app))
{
   // Not relevant.
   return;
}
app.BeforeDelete += AppointmentBeforeDelete;
app.Save();

I also tried adding the event before moving the Appointment:

_appointment.BeforeDelete += AppointmentBeforeDelete;
_appointment.Save();
if (!(_appointment.Move(timFolder) is AppointmentItem app))
{
   // Not relevant.
   return;
}
app.Save();

'_appointment' is the Appointment I want to move.

'timFolder' is the Tim-Calendar.

When using the AppointmentItem.Move() method a new Appointment is created, which I call 'app'.

Note that I tested that the events fires when I don't move the Appointment to the Tim-calendar.

I really have no idea what I'm doing wrong, so I hope someone here can help me.

Thanks in advance,

Frenk

解决方案

Hello Frenk,

I could reproduce your issue. I would suggest you go to Outlook File->Feedback to submit a feedback for this issue.

As workaround, below code maybe look strange but it do really work for me.

 AppointmentItem app = _appointment.Move(timFolder);
                    // after accessing the GlobalAppointmentID property, event works.
                    var a = app.GlobalAppointmentID;
                    app.BeforeDelete += AppointmentBeforeDelete;               
                    app.Save();

Best Regards,

Terry


这篇关于AppointmentItem事件不会在自定义日历/文件夹中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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