Global Address List Dialog Focus

  • Thread starter Thread starter FredF
  • Start date Start date
F

FredF

I am attempting to use the Outlook 2007 Address Book Dialog to allow users
to use a familiar interface to select email recepients. it always displays
the dialog minumized behind outlook, or the application, so the user would
not know the dialog is displayed unless they click on outlook in the bottom
status bar.

I have attempted to use the AppActivate function to force outlook as having
the focus. I also searchered outlook develpment fourms and documentation,

I am developing with VS 2008 on a XP SP3 machine

Any Help is Appreciated

Here is my Code used on a button_click Event:

Private Sub btnGetContacts_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnGetContacts.Click


Dim strEmailAddess As String = ""
Dim i As Integer
Dim AddString() As String = Nothing
Dim Address As String = ""
'set up outlook application and NameSpace
Dim olApp As Outlook.Application = New Outlook.Application
Dim Ns As Outlook.NameSpace = olApp.GetNamespace("MAPI")
Dim olAddressList As Outlook.AddressList = Ns.GetGlobalAddressList

oDialog = Ns.GetSelectNamesDialog


'Opens Oulook Address Name List Dialog
With oDialog
.InitialAddressList = olAddressList
.AllowMultipleSelection = True
.Display()

'Loop through the selected recepients
If .Recipients.Count > 0 Then
For i = 1 To .Recipients.Count
AddString = Split(.Recipients.Item(i).Address, "/")
Address = AddString(4).ToString
Address = LCase(Mid(Address, InStr(Address, "=") + 1,
Len(Address))) & "@Mycompany.com"
If i = .Recipients.Count Then
strEmailAddess = strEmailAddess & Trim(Address)
Else
strEmailAddess = strEmailAddess & Trim(Address) & ";"
End If
Next
txtRouteToEmail.Text = strEmailAddess 'Upates text box to
display selected Names
End If

End With

oDialog = Nothing
olApp = Nothing
Ns = Nothing
olAddressList = Nothing

End Sub
 
Back
Top