简体   繁体   English

VSTO - C#中的Outlook事件处理程序

[英]VSTO - Outlook event handler in C#

I have a need to display a custom form instead of the default inspector form for an outlook appointment item. 我需要为Outlook预约项显示自定义表单而不是默认检查器表单。 I want to do this in C#. 我想在C#中这样做。

There's a good tutorial on devx but it's using VB, and I want to use C#. devx上有一个很好的教程,但它使用VB,我想使用C#。 So I've translated the code to C# and I'm having a problem where I need to override the Open event handler for the AppointmentItem (called mcAI ). 所以我已经将代码翻译成C#,我遇到了一个问题,我需要覆盖AppointmentItemOpen事件处理程序(称为mcAI )。 In the above mentioned tute, they say to do the following in VB: 在上面提到的tute中,他们说要在VB中执行以下操作:

Private Sub tyAI_Open(ByRef Cancel As Boolean) Handles tyAI.Open
    Cancel = True
End Sub

which to me translates as: 我翻译为:

private void mcAI_Open(out bool Cancel)
{
    Cancel = true;
}

(Note I've tried this with and without an out and ref parameter, and with/without an object as the first param too) (注意我已经尝试了这个有和没有outref参数,并且有/没有对象作为第一个参数)

However we need to register that this is a with the event, so I've put in this code: 但是我们需要注册这是一个事件,所以我输入了这段代码:

mcAI.Open += 
    new Microsoft.Office.Interop.Outlook.ItemEvents_10_OpenEventHandler(mcAI_Open);

But I can't compile this as I get the error: 但是当我收到错误时,我无法编译它:

No overload for 'mcAI_Open' matches delegate 'Microsoft.Office.Interop.Outlook.ItemEvents_10_OpenEventHandler'

Any ideas on how I am supposed to register my function for the Open event of the AppointmentItem ? 关于如何为AppointmentItemOpen事件注册我的函数的任何想法? Thanks in advance. 提前致谢。

(BTW there's a MSDN QA which suggests my code should work and yet I'm still stuck.) (顺便说一句,有一个MSDN QA ,它表明我的代码应该可以运行,但我仍然卡住了。)

Theoretically, this should work: 从理论上讲,这应该工作:

private void mcAI_Open(ref bool Cancel)
{
    Cancel = true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM