Sending from Word with Outlook COM Addin

J

james

I have an ATL/C++ COM Addin that processes the message on the
Application::OnSend Event.

It works without problem using Office2003, in all the different ways a
mail can be sent from the desktop. (Outlook, Word, etc,
Shell|SendTo|Mail Recipient)

It works _most_ of the time using Office XP. The following two
scenarios fail.
1/ Using OfficeXP SP3, with Outlook not active.
Start a word doc, select FIle | Send To | Mail Recepient (As
Attachment) ; enter the recipient details, and hit send.
The addin activates, BUT, the message isn't sent , and the
inspector remains open.
The inspector window can be closed manually.

2/ Using OfficeXP SP3, with Outlook not active.
Right click on, say, a doc on the desktop. Select Send To | Mail
Recipient, enter recipient details and hit send.
The addin activates, BUT, the message isn't sent, and the inspector
remains open.
If the inspector is closed manually, the windows explorer crashes,
....

The code causing problems seems to be the second last line below (note
- error handling code and other functionality removed):
CComPtr<Outlook::_Application> spApplication;
....
CComPtr<Outlook::_NameSpace> spSession;
spApplication->get_Session(&spSession);

IUnknown* pUnk = NULL;

spSession->get_MAPIOBJECT(&pUnk);
...
pUnk->Release();

Commenting out the last two lines makes the code that is there work
correctly. (Further functions that need to use the pUnk pointer are
also disabled)

(I need the LPMAPISESSION pointer to access the Primary User's SMTP
address, and don't want any security prompts.)
 

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