Can any one guide me or provide the link to retrieve Address from outllok address book
Thanks in Advance
In versions before Outlook 2007, Outlook does not directly expose the right-click context menu in its CommandBars collection. You will, however, see a new right-click command is when the item selected is using a custom form that includes one or more custom actions. You can also add a custom action without using a custom form, as demonstrated at http://www.outlookcode.com/codedetail.aspx id=526
Richard Kagerer has posted a code sample at http://www.outlookcode.com/codedetail.aspx id=314 that shows how you might trick Outlook into exposing the context menu through Explorer.CommandBars.
The C++ sample add-in at http://www.codeproject.com/atl/outlook2k3addin.asp also shows a technique for working with the context menu.
Outlook 2007 provides Application-level events for the most commonly used context menus.
In none of these cases, however, are context menus in the address book exposed.
The object browser is your friend. If you used it, you'd see that the ol* values are constants from the Outlook object model. CommandBars and CommandBarButton are classes in the Office object model, while MsoControlType is an Office enumeration. Therefore, you need to import the Outlook and Office namespaces.
In versions before Outlook 2007, Outlook does not directly expose the right-click context menu in its CommandBars collection. You will, however, see a new right-click command is when the item selected is using a custom form that includes one or more custom actions. You can also add a custom action without using a custom form, as demonstrated at http://www.outlookcode.com/codedetail.aspx id=526
Richard Kagerer has posted a code sample at http://www.outlookcode.com/codedetail.aspx id=314 that shows how you might trick Outlook into exposing the context menu through Explorer.CommandBars.
The C++ sample add-in at http://www.codeproject.com/atl/outlook2k3addin.asp also shows a technique for working with the context menu.
Outlook 2007 provides Application-level events for the most commonly used context menus.
public class ThisAddIn
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
'Option Explicit
'CommandBars object of Active Explorer. Note we really should
'set this object whenever the active explorer window changes, but
'that's not done in this example.
Dim WithEvents ActiveExplorerCBars As Microsoft.Office.Core.CommandBars
Dim WithEvents ContextButton As Microsoft.Office.Core.CommandBarButton
'Dim WithEvents CBBAbout As CommandBarButton
'A flag, so we don't respond to our own changes in OnUpdate
Private IgnoreCommandbarsChanges As Boolean
'Run this first
Public Sub Install()
ActiveExplorerCBars = Application.ActiveExplorer().CommandBars
End Sub
Private Sub ContextButton_Click(ByVal Ctrl As Office.CommandBarButton, ByVal CancelDefault As Boolean)
MsgBox("You clicked " & Ctrl.Caption)
End Sub
'This fires when the user right-clicks a contact, and also for a lot of other things!
Private Sub ActiveExplorerCBars_OnUpdate()
Dim bar As Microsoft.Office.Core.CommandBar
If IgnoreCommandbarsChanges Then Exit Sub
'Try for the context menu
On Error Resume Next
bar = ActiveExplorerCBars.Item("Malleswar")
On Error GoTo 0
If Not bar Is Nothing Then
AddContextButton(bar)
End If
End Sub
Private Sub AddContextButton(ByVal ContextMenu As Microsoft.Office.Core.CommandBar)
Dim b As Microsoft.Office.Core.CommandBarButton
Dim Control As Microsoft.Office.Core.CommandBarControl
'User cannot play with the Context Menu, so we know there is at most
'only one copy of the control there
Control = ContextMenu.FindControl(Type:=Microsoft.Office.Core.MsoControlType.msoControlButton, Tag:="Test Button")
If Control Is Nothing Then
'Unprotect context menu
ChangingBar(ContextMenu, Restore:=False)
'Create the control
Control = ContextMenu.Controls.Add(Type:=Microsoft.Office.Core.MsoControlType.msoControlButton)
'Set up control
Control.Tag = "Test Button"
Control.Caption = "Test Button"
Control.Priority = 1
Control.Visible = True
'Reprotect context menu
ChangingBar(ContextMenu, Restore:=True)
'Hook the Click event
ContextButton = Control
Else
'Note that Outlook has a bad habbit of changing our Context Menu buttons
'to be priority dropped.
Control.Priority = 1
End If
End Sub
'Called once to prepare for changes to the command bar, then again with
'Restore = true once changes are complete.
Private Sub ChangingBar(ByVal bar As Microsoft.Office.Core.CommandBar, ByVal Restore As Boolean)
Static oldProtectFromCustomize, oldIgnore As Boolean
If Restore Then
'Restore the Ignore Changes flag
IgnoreCommandbarsChanges = oldIgnore
'Restore the protect-against-customization bit
If oldProtectFromCustomize Then bar.Protection = _
bar.Protection And Microsoft.Office.Core.MsoBarProtection.msoBarNoCustomize
Else
'Store the old Ignore Changes flag
oldIgnore = IgnoreCommandbarsChanges
IgnoreCommandbarsChanges = True
'Store old protect-against-customization bit setting then clear
'CAUTION: Be careful not to alter the property if there is no need,
'as changing the Protection will cause any visible CommandBarPopup
'to disappear unless it is the popup we are altering.
oldProtectFromCustomize = bar.Protection And Microsoft.Office.Core.MsoBarProtection.msoBarNoCustomize
If oldProtectFromCustomize Then bar.Protection = bar.Protection _
And Not Microsoft.Office.Core.MsoBarProtection.msoBarNoCustomize
End If
End Sub
End class