Outlook addin started directly by inspector window (c# .net 3.5)

T

Tim van Rooijen

Hello,

I'm developing an outlook add in with visual studio 2008 .net 3.5
The program allows user to save email in a cms from the email inspector window.
The add-in works correctly when outlook is started normally .
But when outlook is not yet started and you open a msg file it won’t work correctly. An inspector window opens (really slow ) and I’m not able to catch the current mailitem.
How can you catch the current mailitem when the inspector window is opened directly ?
PS.
Sorry for my poor English I’m dutch


private Outlook.Inspectors Inspectors;
internal static Outlook.MailItem Item;


private Outlook.Inspectors Inspectors;
internal static Outlook.MailItem Item;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Inspectors = Application.Inspectors;
// Extra event handler voor het new inspector event
Inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(
inspectors_NewInspector);
}


private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
Inspectors.NewInspector -= new Outlook.InspectorsEvents_NewInspectorEventHandler(inspectors _NewInspector);
Inspectors = null;
Item = null;
}

void inspectors_NewInspector(Outlook.Inspector Inspector)
{
if (Inspector.CurrentItem is Outlook.MailItem)
{
Item = (Outlook.MailItem)Inspector.CurrentItem;
}
}
 
K

Ken Slovak - [MVP - Outlook]

Adding an Inspector using a Simple MAPI call such as Send To or by opening
an MSG file from the file system doesn't fire the NewInspector event. It
opens the Inspector modally, adds it to the Inspectors collection, but
NewInspector will never fire.

The only workaround I'm aware of is to use a timer and check the Inspectors
collection at timed intervals and see if any members of the Inspectors
collection aren't already being handled by your code. You would also have to
use an interlock so if your timer fires and you check the Inspectors
collection before NewInspector fires in a normal new Inspector that you
don't handle the Inspector twice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top