I have an Outlook plugin. I have an inspector handler that calls a method when a new window is opened. I want the method to do 'something' only if the current window is a forward message window (the window that opens when you click the forward button in an email). My current code works but it works with all new windows, including Reply/ New Email etc.
Any help how I can check to see if the new window is a forward email window?
My code:
...
Outlook.Inspectors olInspectors;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{ ......
olInspectors = this.Application.Inspectors;
olInspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(Forward_Message_Inspector);
}
void Forward_Message_Inspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
//how do I check here if current window is a forward message window?
//and then do something
}
Thank you in advance for any help.
You can check this using Subject
of the Email.
void Forward_Message_Inspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
if (mailItem != null)
{
if (mailItem.Subject.StartsWith("FW: "))
{
//do something here
}
}
}
You can also do this by analyzing Mail Body
You can wire up your Inspector handler/wrapper to only process windows when the MailItem.Forward
event occurs - but you'd also need a MailItem
handler/wrapper.
Another approach is to check the values of PR_ICON_INDEX
(will be 262 for forwards) or PR_LAST_VERB_EXECUTED
(104 for forwards) on the MailItem
using the PropertyAccessor
object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With