Script component as an Outlook COM add-in

S

Stuart Langridge

I'm trying to write an Outlook COM add-in as a Windows Script Component.
AFAICT, to do this I need to implement the IDTExtensibility2 interface,
which means that I need to implement the methods OnConnection,
OnDisconnection, OnAddInsUpdate, OnStartupComplete, and OnBeginShutdown.
I've created a script component and registered it, and then set it as an
Outlook add-in (by adding the appropriate registry keys in
HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins\SendAndFile.WSC,
as http://support.microsoft.com/default.aspx?scid=kb;EN-US;238228 dictates.
However, the add-in won't run in Outlook; it appears in the COM Addins
Manager, but when I try to start it (by checking the checkbox next to it and
hitting OK) there is some kind of error: returning to the CAM says (next to
LoadBehaviour) that the add-in was not loaded because a runtime error
occurred. There is no visible error occurring (no dialog boxes or similar).
The code for the script component is below: as you can see, it doesn't *do*
anything at this stage (I'd just like to get it instantiated before I add
functionality). Am I implementing something incorrectly? Is there any way
that I can see *what* the runtime error that is generated when loading the
addin *is*?

Thanks in advance,

Stuart Langridge
Information Architect
Mills & Reeve

<?xml version="1.0"?>
<component>

<?component error="true" debug="true"?>

<registration
description="SendAndFile"
progid="SendAndFile.WSC"
version="1.00"
classid="{8181fc23-cec8-4b4d-85e4-65c55e6d144f}"</registration>

<public>
<method name="OnConnection">
<PARAMETER name="Application"/>
<PARAMETER name="ConnectMode"/>
<PARAMETER name="AddInInst"/>
<PARAMETER name="Custom"/>
</method>
<method name="OnDisconnection">
<PARAMETER name="RemoveMode"/>
<PARAMETER name="Custom"/>
</method>
<method name="OnAddInsUpdate">
</method>
<method name="OnStartupComplete">
</method>
<method name="OnBeginShutdown">
</method>
<method name="display">
</method>
</public>

<script language="VBScript">
<![CDATA[

function OnConnection(Application,ConnectMode,AddInInst,Custom)
'msgbox "hello"
Stop
OnConnection = true
end function

function OnDisconnection(RemoveMode,Custom)
OnDisconnection = true
end function

function OnAddInsUpdate(Custom)
OnAddInsUpdate = true
end function

function OnStartupComplete(Custom)
OnStartupComplete = true
end function

function OnBeginShutdown(Custom)
OnBeginShutdown = true
end function

function display()
display = "Temporary Value"
end function

]]>
</script>

</component>
 
K

Ken Slovak - [MVP - Outlook]

Not possible, an Outlook COM addin must be a DLL.




Stuart Langridge said:
I'm trying to write an Outlook COM add-in as a Windows Script Component.
AFAICT, to do this I need to implement the IDTExtensibility2 interface,
which means that I need to implement the methods OnConnection,
OnDisconnection, OnAddInsUpdate, OnStartupComplete, and OnBeginShutdown.
I've created a script component and registered it, and then set it as an
Outlook add-in (by adding the appropriate registry keys in
HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins\SendAndFile.WSC,
as http://support.microsoft.com/default.aspx?scid=kb;EN-US;238228 dictates.
However, the add-in won't run in Outlook; it appears in the COM Addins
Manager, but when I try to start it (by checking the checkbox next to it and
hitting OK) there is some kind of error: returning to the CAM says (next to
LoadBehaviour) that the add-in was not loaded because a runtime error
occurred. There is no visible error occurring (no dialog boxes or similar).
The code for the script component is below: as you can see, it doesn't *do*
anything at this stage (I'd just like to get it instantiated before I add
functionality). Am I implementing something incorrectly? Is there any way
that I can see *what* the runtime error that is generated when loading the
addin *is*?

Thanks in advance,

Stuart Langridge
Information Architect
Mills & Reeve

<?xml version="1.0"?>
<component>

<?component error="true" debug="true"?>

<registration
description="SendAndFile"
progid="SendAndFile.WSC"
version="1.00"
classid="{8181fc23-cec8-4b4d-85e4-65c55e6d144f}"</registration>

<public>
<method name="OnConnection">
<PARAMETER name="Application"/>
<PARAMETER name="ConnectMode"/>
<PARAMETER name="AddInInst"/>
<PARAMETER name="Custom"/>
</method>
<method name="OnDisconnection">
<PARAMETER name="RemoveMode"/>
<PARAMETER name="Custom"/>
</method>
<method name="OnAddInsUpdate">
</method>
<method name="OnStartupComplete">
</method>
<method name="OnBeginShutdown">
</method>
<method name="display">
</method>
</public>

<script language="VBScript">
<![CDATA[

function OnConnection(Application,ConnectMode,AddInInst,Custom)
'msgbox "hello"
Stop
OnConnection = true
end function

function OnDisconnection(RemoveMode,Custom)
OnDisconnection = true
end function

function OnAddInsUpdate(Custom)
OnAddInsUpdate = true
end function

function OnStartupComplete(Custom)
OnStartupComplete = true
end function

function OnBeginShutdown(Custom)
OnBeginShutdown = true
end function

function display()
display = "Temporary Value"
end function

]]>
</script>

</component>
 
S

Stuart Langridge

Ken Slovak - said:
Not possible, an Outlook COM addin must be a DLL.

I don't want to appear stupid here, but are WSC's not "real" COM objects in
some way? I thought that the point was that COM objects were all the same,
and as long as they implemented the appropriate interface they would work
OK? I've seen people writing Outlook addins in Python, say (the SpamBayes
project is an example), and that just generates a COM object.

Stuart Langridge
Information Architect
Mills & Reeve
 
K

Ken Slovak - [MVP - Outlook]

As far as I know an Outlook COM addin must be a DLL. How you generate it and
with what language is up to you.
 

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