I'm trying to build a simple COM addin for Outlook using VB.NET 2003. I've
downloaded this example as a start point...
http://msdn.microsoft.com/library/de...addinvbnet.asp
But the onConnect method fails with Object reference to set to an
instance...bla bla bla.
Here is the code from the method as it exists in my addin (pretty much the
same as the example)
'Extensibility.IDTExtensibility2 Event Stubs
Public Sub OnConnection(ByVal application As Object, ByVal
connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object,
ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnConnection
Dim oApp As Outlook.Application
Dim oType As Type
Dim GetProgID As Object
Dim MyProgID As String
Dim oArgs As Object()
'Dim Reg As RegistryKey
'Dim WriteDiagnostics As Integer
'Dim strKey As String
Try
MsgBox("Mail manager conencted", MsgBoxStyle.Information)
'Use InvokeMember to get ProgID of addInInst object
oType = addInInst.GetType
GetProgID = oType.InvokeMember("ProgID", _
BindingFlags.Public Or BindingFlags.GetField Or
BindingFlags.GetProperty, _
Nothing, _
addInInst, _
oArgs)
MyProgID = CType(GetProgID, String)
'Convert application from generic object to
Outlook.Application
oApp = CType(application, Outlook.Application)
'Don't call InitHandler if Explorers.Count = 0 and
Inspectors.Count = 0
If oApp.Explorers.Count = 0 And oApp.Inspectors.Count = 0
Then
Exit Sub
End If
'Evaluate ConnectMode
Select Case connectMode
Case ext_ConnectMode.ext_cm_AfterStartup
Case ext_ConnectMode.ext_cm_CommandLine
Case ext_ConnectMode.ext_cm_External
Case ext_ConnectMode.ext_cm_Solution
Case ext_ConnectMode.ext_cm_Startup
Case ext_ConnectMode.ext_cm_UISetup
End Select
' Initialize COMAddin object with this connect object to
allow
' external clients to get access to exposed features
oApp.COMAddIns.Item(MyProgID.ToString).Object = Me
'Call InitHandler
m_BaseClass.InitHandler(oApp, MyProgID)
Catch ex As SystemException
MsgBox(ex.Message & " : " & ex.Message,
MsgBoxStyle.Critical, "Mail Manager")
End Try
End Sub