问题
I am trying to identify the item type on the item send event. I am very close to getting there but the program is not recognising the current item type if a different window has been opened previously.
Here is the code used:
void Application_ItemSend(object Item, ref bool Cancel)
{
inspectors = this.Application.Inspectors;
currentExplorer = this.Application.ActiveExplorer();
currentExplorer.InlineResponse += ThisAddIn_InlineResponse;
Outlook.Inspector inspector = Application.ActiveInspector();
Item = inspector.CurrentItem;
try
{
//Item = inspector.CurrentItem;
if (Item == currentAppointment)
{
TypeCheck = "inspector";
}
My understanding of that code, is that when I select the send button, this code will determine the current type of window that is open and set Item to the corresponding type.
Any help or guidance as to why this is not working would be greatly appreciated!
回答1:
No, all you have to do is the following:
void Application_ItemSend(object Item, ref bool Cancel)
{
Outlook.MailItem mailItem = Item as Outlook.MailItem;
if (mailItem != null)
{
MessageBox.Show("I am a MailItem");
}
else
{
Outlook.MeetingItem meetingItem = Item as Outlook.MeetingItem;
if (meetingItem != null)
{
MessageBox.Show("I am a MeetingItem");
}
}
}
来源:https://stackoverflow.com/questions/37787902/outlook-add-in-selecting-the-active-inspector-on-item-send