在 outlook 的 ItemSend() 方法中关闭检查器(撰写 window)

Close inspector (compose window) inside the ItemSend() method in outlook

我使用 Visual studio 2013 和 Addin express v.7.7.4087 开发了一个 outlook 添加。 我想处理 ItemSend() 并将项目保存到草稿并自动关闭检查器,我们可以做除了关闭检查器之外的所有事情,因为不允许在 ItemSend() 方法内关闭检查器,我使用a windows.forms.timer(关闭计时器内的邮件项目)来执行此操作但最终出现错误,其中显示“RCW 内容已与…………分离”错误

  1. 还有其他方法吗?

  2. 在赎回(for outlook)中,有没有办法做同样的事情?

    private void adxOutlookAppEvents1_ItemSend(object sender, DXOlItemSendEventArgs e)
    {
        Outlook.MailItem mailItem = null;
        Outlook.Recipients recipients = null;
        mailItem = e.Item as Outlook.MailItem;
        try
        {
                // Some code goes here
    
                if (editButtonClicked || swOffline)
                {
                    e.Cancel = true;
    
                    if (swOffline)
                    {
                        mailItem.Save();
                        timer.Start();
                    }
                }        
        }
        catch (Exception ex)
        {
    
        }
        finally
        {
    
        }
    }
    

您使用什么代码关闭检查器window?能具体点吗?

Are there any alternative ways of doing this?

Inspector class 的 Close 方法非常有效。

In redemption (for outlook), is there a way of doing the same thing?

它没有为此提供任何东西。该库基于扩展 MAPI,对 Outlook UI.

一无所知

只要您保留引用的 MailItem 对象,计时器就会正常工作。看起来您的 mailItem 变量是在本地级别声明的,它将被垃圾收集。