Outlook加载项,右Eventhandler

本文关键字:Eventhandler 加载项 Outlook | 更新日期: 2023-09-27 18:20:01

我试图构建一个外接程序,将附件保存为具有特定主题的邮件。到目前为止,这还可以,但我认为我使用了错误的Eventhandler来满足我的需求。

它应该在收到新邮件时启动,然后检查整个收件箱+新邮件。

atm im使用Microsoft.Office.Interop.Outlook.ApplicationEvents_11_NewMailEventHandler()
所以他只是在寻找没有新邮件的收件箱,因为在那一刻,新邮件不是收件箱的一部分

  private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {                 
        this.Application.NewMail += new Microsoft.Office.Interop.Outlook
        .ApplicationEvents_11_NewMailEventHandler(ThisAddIn_NewMail);

    }

我该怎么办?

Outlook加载项,右Eventhandler

您可以假设电子邮件将是未读的,因此您应该能够使用Items.Find/FindNext来查找未读邮件。或者,您可以存储上次处理电子邮件的日期,然后再次使用Items.Find/FindNext搜索CreationTime大于某个值的邮件。