Reputation: 267
I have been developing an Add in for Outlook 2013, and I am currently finding it difficult to find the interface type of the "Popped in" window that appears in Outlook 2013 when replying and forwarding emails.
For Example: For New emails, the interface type is Outlook.MailItem, and for meeting requests, the interface type is Outlook.AppointmentItem.
What interface type can I use to identify the popped in window that appears on reply and forwards in Outlook 2013?
Upvotes: 0
Views: 89
Reputation: 267
My manager sat with me and worked through it and thankfully a solution was found. You can access the "popped in" reply and forward windows by using the following code
//First, declare the interface type of Explorer
public static Outlook.Explorer currentExplorer;
//Create a method to identify the Inline response as a MailItem
private void ThisAddIn_InlineResponse(object Item)
{
if (Item != null)
{
Outlook.MailItem mailItem = Item as Outlook.MailItem;
}
}
//Direct to the ThisAddIn_Startup() method and add an event handler for the Inline Response Method
currentExplorer.InLineResponse += ThisAddIn_InLineResponse;
//Access the popped in reply and forward window where required
object item = null;
item = currentExplorer.ActiveInlineResponse;
Upvotes: 0
Reputation: 49455
When you reply or forward a mail item the new item will be a MailItem object. You may use the folloeing code for determing the item type:
Object selObject = this.Application.ActiveExplorer().Selection[1];
if (selObject is Outlook.MailItem)
{
Outlook.MailItem mailItem =
(selObject as Outlook.MailItem);
itemMessage = "The item is an e-mail message." +
" The subject is " + mailItem.Subject + ".";
mailItem.Display(false);
}
else if (selObject is Outlook.ContactItem)
{
Outlook.ContactItem contactItem =
(selObject as Outlook.ContactItem);
itemMessage = "The item is a contact." +
" The full name is " + contactItem.Subject + ".";
contactItem.Display(false);
}
else if (selObject is Outlook.AppointmentItem)
{
Outlook.AppointmentItem apptItem =
(selObject as Outlook.AppointmentItem);
itemMessage = "The item is an appointment." +
" The subject is " + apptItem.Subject + ".";
}
else if (selObject is Outlook.TaskItem)
{
Outlook.TaskItem taskItem =
(selObject as Outlook.TaskItem);
itemMessage = "The item is a task. The body is "
+ taskItem.Body + ".";
}
else if (selObject is Outlook.MeetingItem)
{
Outlook.MeetingItem meetingItem =
(selObject as Outlook.MeetingItem);
itemMessage = "The item is a meeting item. " +
"The subject is " + meetingItem.Subject + ".";
}
See How to: Programmatically Determine the Current Outlook Item for more information.
Also you may consider checking the MessageClass property of the MailItem class. The MessageClass property links the item to the form on which it is based. When an item is selected, Outlook uses the message class to locate the form and expose its properties, such as Reply commands.
Upvotes: 0