Interop.Outlook Com-Object PropertyChange无法检索新值

时间:2017-12-05 12:07:12

标签: c# vsto office-interop outlook-addin com-interop

我正在尝试在触发SendUsingAccount PropertyChange时检索新的SmtpAddress。

事件被名为“SendUsingAccount”的事件触发,但值未更新。如何从SendUsingAccount获取更新的属性?

private void AutoSignatureRibbon_Load(object sender, RibbonUIEventArgs e)
{
    // Get MailItem
    Microsoft.Office.Interop.Outlook.Inspector inspector = this.Context as Microsoft.Office.Interop.Outlook.Inspector;
    Microsoft.Office.Interop.Outlook.MailItem mailItem = inspector.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem;

    // Property Change Event
    mailItem.PropertyChange += MailItem_PropertyChange;

    // Get Sender
    string senderMail = mailItem.SendUsingAccount.SmtpAddress;
}

private void MailItem_PropertyChange(string Name)
{
    // Get Updated MailItem
    Microsoft.Office.Interop.Outlook.Inspector inspector = this.Context as Microsoft.Office.Interop.Outlook.Inspector;
    Microsoft.Office.Interop.Outlook.MailItem mailItem = inspector.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem;

    // Get Sender
    string senderMail = mailItem.SendUsingAccount.SmtpAddress;
}

0 个答案:

没有答案