Outlook插件之防意外关闭

0x00 前言

换成Outlook之后,遇到一个很严重的问题——爪爪表示很习惯的点击关闭,之后...之后就真的关了,一天收到邮件的时候才发现Outlook没运行... (〒︿〒)
为了防止自己的手欠,于是自己写个插件来解决这个问题。 (。・ω・。)

0x01 开发

创建好一个插件的时候,需要注意的是shutdown函数在office2010版本之后不再是关闭Outlook之前执行了。查阅文档发现关闭Outlook时调用的函数是

((Outlook.ApplicationEvents_11_Event)Application).Quit

添加关闭后执行的方法,这里为了防止彻底无法关闭Outlook,增加了一个判断,当按住Shift健时,点击关闭,则可以彻底关闭Outlook。

private void ThisAddIn_Quit()
{
    if ((Control.ModifierKeys & Keys.Shift) == Keys.None)
    {
        ProcessStartInfo psOutlook = new ProcessStartInfo("OUTLOOK.EXE", "/recycle");
        psOutlook.WindowStyle = ProcessWindowStyle.Minimized;
        Process.Start(psOutlook);
    }
}

((Outlook.ApplicationEvents_11_Event)Application).Quit += new Outlook.ApplicationEvents_11_QuitEventHandler(ThisAddIn_Quit);

编译安装上就可以了,每次如果点击关闭之后,会直接重启起来一个Outlook。

代码和编译好的放到了这里,欢迎Star和吐槽。(ノ>ω<)ノ

猜你喜欢

转载自blog.csdn.net/weixin_34270865/article/details/90968510