Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Calling an Add-in method from another Application

Geek News

Calling an Add-in method from another Application
"David" <maillist[ at ]samarskite.com> 2/2/2007 1:14:45 AM
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?


Re: Calling an Add-in method from another Application
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 2/2/2007 3:50:30 PM
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"David" <maillist[ at ]samarskite.com> wrote in message
news:7DC38036-D583-41DF-9A83-32A7EC55E422[ at ]microsoft.com...
[Quoted Text]
>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?
>
>

Re: Calling an Add-in method from another Application
"David" <maillist[ at ]samarskite.com> 2/8/2007 8:02:10 PM
This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C74B78.F6D40FC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks Ken.=20
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.

------=_NextPart_000_0007_01C74B78.F6D40FC0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.5730.11" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Thanks Ken. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>It's taken I while to work through the =
post and=20
build an example, I've got a working prototype now.</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DTahoma=20
size=3D2></FONT></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>It was the </FONT><FONT face=3DArial =
size=3D2><FONT=20
face=3DCourier><STRONG>RequestComAddInAutomationService</STRONG></FONT> =
call that=20
nailed it.</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DTahoma=20
size=3D2></FONT></FONT></FONT> </DIV></BODY></HTML>

------=_NextPart_000_0007_01C74B78.F6D40FC0--

Re: Calling an Add-in method from another Application
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 2/8/2007 9:19:35 PM
This is a multi-part message in MIME format.

------=_NextPart_000_0066_01C74B9C.EC0C5100
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

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

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"David" <maillist[ at ]samarskite.com> wrote in message
news:eAtugw7SHHA.5060[ at ]TK2MSFTNGP02.phx.gbl...
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.

------=_NextPart_000_0066_01C74B9C.EC0C5100
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.3020" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Yes, that's the new twist they threw in =
to keep us=20
MVPs busy <g></FONT></DIV>
<DIV><BR>-- <BR>Ken Slovak<BR>[MVP - Outlook]<BR><A=20
href=3D"http://www.slovaktech.com">http://www.slovaktech.com</A><BR>Autho=
r:=20
Absolute Beginner's Guide to Microsoft Office Outlook 2003<BR>Reminder =
Manager,=20
Extended Reminders, Attachment Options<BR><A=20
href=3D"http://www.slovaktech.com/products.htm">http://www.slovaktech.com=
/products.htm</A></DIV>
<DIV> </DIV>
<DIV> </DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"David" <<A=20
=
href=3D"mailto:maillist[ at ]samarskite.com">maillist[ at ]samarskite.com</A>> =
wrote in=20
message <A=20
=
href=3D"news:eAtugw7SHHA.5060[ at ]TK2MSFTNGP02.phx.gbl">news:eAtugw7SHHA.5060=
[ at ]TK2MSFTNGP02.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks Ken. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>It's taken I while to work through =
the post and=20
build an example, I've got a working prototype now.</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DTahoma=20
size=3D2></FONT></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>It was the </FONT><FONT face=3DArial =
size=3D2><FONT=20
=
face=3DCourier><STRONG>RequestComAddInAutomationService</STRONG></FONT> =
call=20
that nailed it.</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DTahoma=20
size=3D2></FONT></FONT></FONT> </DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0066_01C74B9C.EC0C5100--

Re: Calling an Add-in method from another Application
"David" <maillist[ at ]samarskite.com> 3/9/2007 11:09:47 PM
This is a multi-part message in MIME format.

------=_NextPart_000_004D_01C7625C.FB663040
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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 =3D new Outlook.ApplicationClass(); =
=20
Outlook.NameSpace olNS =3D olApp.GetNamespace("MAPI");
MSOffice.COMAddIns addIns =3D 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?=20

Any thoughts on what I should do?

Thanks
------=_NextPart_000_004D_01C7625C.FB663040
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16397" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi - this is all going well, =
but..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>My application that attempts to use the =
externally=20
available call can't seem to get hold of the add-in.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I get the following =
exception:</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>System.Runtime.InteropServices.COMException=20
(0x80010001): Call was rejected by callee. (Exception from HRESULT: =
0x80010001=20
(RPC_E_CALL_REJECTED))</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The calls I am making are:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>    =
Outlook.ApplicationClass olApp =3D=20
new Outlook.ApplicationClass();    <BR>    =

Outlook.NameSpace olNS =3D =
olApp.GetNamespace("MAPI");<BR>   =20
MSOffice.COMAddIns addIns =3D olApp.COMAddIns;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I do not get he error if Outlook is =
running before=20
my application starts.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I suspect this is something to do with =
me trying to=20
access the AddIn before it is loaded - does that sound plausable? =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Any thoughts on what I should =
do?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</DIV></FONT></BODY></HTML>

------=_NextPart_000_004D_01C7625C.FB663040--

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net