I can't read out the subject of the Item which is provided by the Event
ItemsEvents_ItemAddEventHandler(object Item)
I tried to convert this Item to an Outlook.MailItem how it's described on StackOverflow and other sites. But I can't cast it because it's not of type MailItem. But which type is it? If I make a quick watch on it, I can see all the properties like Subject and so on. So the Item object has to be a MailItem.
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Parent.Folders["TFS Notifications"].Items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(TfsNotificationsFolderAdd);
}
private void TfsNotificationsFolderAdd(object Item)
{
Outlook.MailItem mailItem;
if ((mailItem = Item as Outlook.MailItem) != null && PlugInActionscs.GetFileChangeCount(mailItem) >= 10)
mailItem.Importance = Outlook.OlImportance.olImportanceHigh;
}