Calling an Add-in method from another Application

D

David

I have used VSTO SE to create an Outlook 2003 add-in in C#.

I would like to be able to invoke a method of the add-in from a separate
application.
(Similar to pollyanna65 post "Programmatically sending email via Outlook COM
Add-In" below).


I have created the add-in with a public method.
The add-in is installed an functioning correctly.


From another application I get an Outlook.Application class object and
iterate through the COMAddIns collection to find the addin I have created.

What can I do to this COMAddIn object to allow me to call my method? How can
I cast it to something I can use?
 
K

Ken Slovak - [MVP - Outlook]

Look for a thread titled "Outlook 2007 COM add-in callback" in the
microsoft.public.office.developer.com.add-ins group, or google for that
thread.

I posted a C# example of working with a public method in an addin for VSTO
2005 SE. Make sure to read the entire thread, I made a typo in my original
sample code.
 
D

David

Thanks Ken.
It's taken I while to work through the post and build an example, I've got a working prototype now.

It was the RequestComAddInAutomationService call that nailed it.
 
K

Ken Slovak - [MVP - Outlook]

Yes, that's the new twist they threw in to keep us MVPs busy <g>




Thanks Ken.
It's taken I while to work through the post and build an example, I've got
a working prototype now.

It was the RequestComAddInAutomationService call that nailed it.
 
D

David

Hi - this is all going well, but..

My application that attempts to use the externally available call can't seem to get hold of the add-in.
I get the following exception:
System.Runtime.InteropServices.COMException (0x80010001): Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

The calls I am making are:
Outlook.ApplicationClass olApp = new Outlook.ApplicationClass();
Outlook.NameSpace olNS = olApp.GetNamespace("MAPI");
MSOffice.COMAddIns addIns = olApp.COMAddIns;

I do not get he error if Outlook is running before my application starts.

I suspect this is something to do with me trying to access the AddIn before it is loaded - does that sound plausable?

Any thoughts on what I should do?

Thanks
 

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