Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Simple MAPI send and Outlook COM addin (http://www.outlookbanter.com/outlook-vba/91033-simple-mapi-send-outlook-com.html)

Mark Smith[_2_] June 1st 09 02:31 PM

Simple MAPI send and Outlook COM addin
 
I've got a COM addin that adds a toolbar to Outlook inspectors.

In another process I call the Simple MAPI MAPISendMail function. When the
new e-mail dialog pops up, my addin toolbar does not appear. I figured out
that the same behavior happens if I open up a new send e-mail dialog via the
send to mail shell context menu.

I heard a long time ago that in some cases Outlook opens in a mode where no
addins are loaded. However, even if Outlook is already running (in which
case my addin is already loaded), my addin toolbar does not appear. I ran
through it with a debugger, and none of my code is hit for this particular
inspector.

What if I use Extended MAPI to do this? Since it happens for both Simple
MAPI and the shell send to mail context menu, I'm assuming that it won't work
for Extended MAPI either. Is there something else I can do about this or is
it just a limitation of Outlook?

Thanks
Mark Smith

Ken Slovak - [MVP - Outlook] June 1st 09 07:36 PM

Simple MAPI send and Outlook COM addin
 
When a Simple MAPI message is opened by Outlook any addins will run if
Outlook is running already, and if the addin is correctly written it will
run even if Outlook wasn't previously running. It all depends on how the
addin is written and what it does when OnConnection is fired.

A new Inspector opened from a Simple MAPI message is added to the Inspectors
collection, but it doesn't fire the Inspectors.NewInspector() event. Since
that's how most code will discover an Inspector was opened the code won't
know about the new Inspector, unless you scan the Inspectors collection and
account for any open Inspectors that aren't already being handled.

Using Extended MAPI won't help with this, the limitations would be the same.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark Smith" wrote in message
...
I've got a COM addin that adds a toolbar to Outlook inspectors.

In another process I call the Simple MAPI MAPISendMail function. When the
new e-mail dialog pops up, my addin toolbar does not appear. I figured
out
that the same behavior happens if I open up a new send e-mail dialog via
the
send to mail shell context menu.

I heard a long time ago that in some cases Outlook opens in a mode where
no
addins are loaded. However, even if Outlook is already running (in which
case my addin is already loaded), my addin toolbar does not appear. I ran
through it with a debugger, and none of my code is hit for this particular
inspector.

What if I use Extended MAPI to do this? Since it happens for both Simple
MAPI and the shell send to mail context menu, I'm assuming that it won't
work
for Extended MAPI either. Is there something else I can do about this or
is
it just a limitation of Outlook?

Thanks
Mark Smith



Mark Smith[_2_] June 16th 09 02:58 PM

Simple MAPI send and Outlook COM addin
 
Thanks for the reply Ken.

I finally got back to this issue, and I've got a few more questions.

As far as finding the new inspector without the NewInspector event firing,
are you suggesting doing something like a timer based polling? Or is there
some other event to trap? I didn't see anything that looked like it would
work. Maybe I'm looking in the wrong place...

You also say that for the case where Outlook isn't already running the addin
should load. I rechecked my code and the addin does get loaded. However I
tried checking the inspector collection in the OnStartupComplete event, which
is the last one that I get other than the ones for the inspectors or toolbars
themselves. The inspector collection is still empty at this point. So
again, is there some other later event to trap, or am I stuck with a polling
solution here also?

Thanks,
Mark Smith

"Ken Slovak - [MVP - Outlook]" wrote:

When a Simple MAPI message is opened by Outlook any addins will run if
Outlook is running already, and if the addin is correctly written it will
run even if Outlook wasn't previously running. It all depends on how the
addin is written and what it does when OnConnection is fired.

A new Inspector opened from a Simple MAPI message is added to the Inspectors
collection, but it doesn't fire the Inspectors.NewInspector() event. Since
that's how most code will discover an Inspector was opened the code won't
know about the new Inspector, unless you scan the Inspectors collection and
account for any open Inspectors that aren't already being handled.

Using Extended MAPI won't help with this, the limitations would be the same.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark Smith" wrote in message
...
I've got a COM addin that adds a toolbar to Outlook inspectors.

In another process I call the Simple MAPI MAPISendMail function. When the
new e-mail dialog pops up, my addin toolbar does not appear. I figured
out
that the same behavior happens if I open up a new send e-mail dialog via
the
send to mail shell context menu.

I heard a long time ago that in some cases Outlook opens in a mode where
no
addins are loaded. However, even if Outlook is already running (in which
case my addin is already loaded), my addin toolbar does not appear. I ran
through it with a debugger, and none of my code is hit for this particular
inspector.

What if I use Extended MAPI to do this? Since it happens for both Simple
MAPI and the shell send to mail context menu, I'm assuming that it won't
work
for Extended MAPI either. Is there something else I can do about this or
is
it just a limitation of Outlook?

Thanks
Mark Smith




Ken Slovak - [MVP - Outlook] June 16th 09 03:29 PM

Simple MAPI send and Outlook COM addin
 
Polling is the answer to both questions.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark Smith" wrote in message
...
Thanks for the reply Ken.

I finally got back to this issue, and I've got a few more questions.

As far as finding the new inspector without the NewInspector event firing,
are you suggesting doing something like a timer based polling? Or is
there
some other event to trap? I didn't see anything that looked like it would
work. Maybe I'm looking in the wrong place...

You also say that for the case where Outlook isn't already running the
addin
should load. I rechecked my code and the addin does get loaded. However
I
tried checking the inspector collection in the OnStartupComplete event,
which
is the last one that I get other than the ones for the inspectors or
toolbars
themselves. The inspector collection is still empty at this point. So
again, is there some other later event to trap, or am I stuck with a
polling
solution here also?

Thanks,
Mark Smith




All times are GMT +1. The time now is 06:09 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com