我正在使用 C# 开发一个小的 Outlook 插件,但我无法让这个插件正确地取消 ItemSend 过程。我特此考虑以下情况:考虑这个小插件:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
((Outlook.ApplicationEvents_Event)this.Application).ItemSend += new ApplicationEvents_ItemSendEventHandler(ThisAddIn_ItemSend);
}
void ThisAddIn_ItemSend(object Item, ref bool Cancel)
{
System.Windows.Forms.MessageBox.Show("You can't save it, it's in the past!");
Cancel = true;
return;
}
现在,当我尝试更改现有约会项目时,我会在约会窗口中打开它时更改它的一些值,例如位置等。点击约会窗口中的“发送”按钮时,文本框中的消息会按预期显示. 但问题是 Outlook 会忽略此取消并已保存更改。唯一发生的事情是约会窗口没有关闭。但是当简单地关闭窗口而不明确保存时,您可以看到 Outlook 已经接受了您对约会项目所做的更改。
这是预期的行为吗?即使“取消”参数已更改为“true”,是否可以阻止 Outlook 保存更改?