Thank you for your replies - The addin places a new button on the command
bar, that when clicked, opens a new email message with the word "secure" in
the subject line.
That's it - nothing fancy.
The problem is with normal behavior of outlook.
Now if I click on a "mail to" link on any web page, if outlook is closed, it
tries to open, but is stopped and shows the error message "The operation
failed. An object could not be found."
If outlook is open, it fails to open a new email form, as it normally should
when one click s on a "Mail To" link, and shows the error message "The
operation failed. An object could not be found."
Does the error message "The operation failed. An object could not be found."
mean that a dll is missing?
Uninstalling the addin, and reinstalling office does not help.
Here is the code for the addin.:
Imports Microsoft.Office.Core
Imports Extensibility
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports Outlook = Microsoft.Office.Interop.Outlook
<GuidAttribute("27616BF0-5F8A-4692-987B-E6A98843DE60"),
ProgIdAttribute("SecureEmailButton.Connect")> _
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim WithEvents btnSecure As CommandBarButton
Dim applicationObject As Object
Dim addInInstance As Object
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
Dim commandBars As CommandBars = applicationObject.ActiveExplorer().
CommandBars
Try
commandBars("Standard").Controls("btnSecure").Delete(System.
Reflection.Missing.Value)
btnSecure.Delete()
btnSecure = Nothing
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar
Dim activeExplorer = applicationObject.GetType().
InvokeMember("ActiveExplorer", BindingFlags.GetProperty, Nothing,
applicationObject, Nothing)
On Error Resume Next
oCommandBars = CType(activeExplorer.GetType().
InvokeMember("CommandBars", BindingFlags.GetProperty, Nothing,
activeExplorer, Nothing), CommandBars)
'End If
oStandardBar = oCommandBars.Item("Standard")
' In case the button was not deleted, use the existing one.
btnSecure = oStandardBar.Controls.Item("Secure Email")
If btnSecure Is Nothing Then
'btnSecure = oStandardBar.Controls.Add(, , , 1, True)
btnSecure = oStandardBar.Controls.Add(1)
With btnSecure
.Visible = True
.Caption = "Secure Email"
.Style = MsoButtonStyle.msoButtonIconAndCaption
.FaceId = 225 'lock icon
.Tag = "Secure Email"
.OnAction = "!<SecureEmailButton.Connect>"
End With
End If
' Display a simple message to show which application you started in.
' MsgBox("Started in " & applicationObject.Name & ".")
oStandardBar = Nothing
oCommandBars = Nothing
End Sub
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.
ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.
IDTExtensibility2.OnDisconnection
On Error Resume Next
If RemoveMode <> Extensibility.ext_DisconnectMode.
ext_dm_HostShutdown Then _
Call OnBeginShutdown(custom)
applicationObject = Nothing
End Sub
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
applicationObject = application
addInInstance = addInInst
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup)
Then _
Call OnStartupComplete(custom)
End Sub
Private Sub btnSecure_Click(ByVal Ctrl As Microsoft.Office.Core.
CommandBarButton, ByRef CancelDefault As Boolean) Handles btnSecure.Click
' Create an instance of the MailItem
Dim newMessage As Outlook.MailItem
newMessage = applicationObject.CreateItem(Outlook.OlItemType.
olMailItem)
newMessage.Subject = "[secure]"
newMessage.Display()
newMessage = Nothing
End Sub
End Class
Thanks
Bob