【问题标题】:OutLook MailItem send event doesn't workOutLook MailItem 发送事件不起作用
【发布时间】:2017-04-04 19:35:41
【问题描述】:

我使用 Microsoft.Office.Interop.Outlook 生成一条消息并为用户打开它。当用户在 Outlook 中发送消息时,我想捕获此事件。不像本 SO 中所讨论的那样:

capture the Outlook 2013 Send event

我在这里捕获所有已发送的电子邮件,而不仅仅是生成的。

public static MailItem CreateMail() 
{
    Application outlook = new Application();
    MailItem mailItem = outlook.CreateItem(OlItemType.olMailItem);
    // set recipients, body, ect..
    mailItem.Send += MailItemSendedHandler;
    Inspector inspector = mailItem.GetInspector;
    inspector.Activate();
    return mailItem;
}

static void MailItemSendedHandler(ref bool isSended) 
{
}

MailItem 有一个Send() 方法和一个Send 事件。当我订阅时,我收到错误:

不能分配给“发送”,因为它是一个方法组。

如何为我的 MailItem 捕获 Send 事件?

【问题讨论】:

    标签: c# outlook office-interop mailitem


    【解决方案1】:

    MailItem 是一个继承自接口_MailItemItemEvents_10_Event 的接口。他们都有Send。 (在 _MailItem 中它是一个方法,在 ItemEvents_10_Events 中它是一个事件)。我认为我们有冲突,需要明确定义我们要使用哪个Send

    ((ItemEvents_10_Event)mailItem).Send += new ItemEvents_10_SendEventHandler(MailItemSendedHandler);
    
    static void MailItemSendedHandler(ref bool isSended) 
    {
    }
    

    【讨论】:

    • 请补充说明
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-19
    • 1970-01-01
    相关资源
    最近更新 更多