I have an Outlook ribbon of the following type: Microsoft.Outlook.Mail.Compose, Microsoft.Outlook.Mail.Read
I need to enable or disable a button from this ribbon, based on the content (body) of the mail item, and I was thinking to do this on the ribbon's Load event.
I have the following code, but the ActiveInspector is always null.
private vo开发者_如何学Cid RiverRaftRibbon_Load(object sender, RibbonUIEventArgs e)
{
var application = Globals.ThisAddIn.Application;
var inspector = application.ActiveInspector();
MailItem myMailItem = (MailItem)inspector.CurrentItem;
string projectName;
DateTime? dueDate;
if (Common.ParserHelper.IsRiverRaftEmail(mail.HTMLBody, out projectName, out dueDate))
{
btnAccept.Enabled = true;
}
else
btnAccept.Enabled = false;
}
Thank you!
Try this:
var application = Globals.ThisAddIn.Application;
Outlook.Selection selection = application.ActiveExplorer().Selection;
mailItem = selection[1] as Outlook.MailItem;
精彩评论