I have written this code, below, which populates a list box with outlook contact items. This is working very well. I have the List box row source type set as Value List. The code simply builds the Row source string and inserts.
The issue I have though is that the list is not in Alphabetical order. Is there anyway to get the For Each , Next code to run through the folder, selecting the Items alphabetically so that the string has each item placed in the string in the correct order.
code:
Dim Outlook As New Outlook.Application
Dim NameSpace As NameSpace
Set NameSpace = Outlook.GetNamespace("MAPI")
Dim ContactFolder As MAPIFolder
Set ContactFolder = NameSpace.GetDefaultFolder(olFolderContacts)
Dim ContactItem As Variant
Dim List As String
For Each ContactItem In ContactFolder.Items
List = List & "'" & ContactItem.FullName & "';'" & ContactItem.Email1DisplayName & "';'" & ContactItem.Email1Address & "';"
Next ContactItem
Me.Contact_Select_List.RowSource = "Full Name;Display Name;E-Mail;" & List
Regards
IC
The issue I have though is that the list is not in Alphabetical order. Is there anyway to get the For Each , Next code to run through the folder, selecting the Items alphabetically so that the string has each item placed in the string in the correct order.
code:
Dim Outlook As New Outlook.Application
Dim NameSpace As NameSpace
Set NameSpace = Outlook.GetNamespace("MAPI")
Dim ContactFolder As MAPIFolder
Set ContactFolder = NameSpace.GetDefaultFolder(olFolderContacts)
Dim ContactItem As Variant
Dim List As String
For Each ContactItem In ContactFolder.Items
List = List & "'" & ContactItem.FullName & "';'" & ContactItem.Email1DisplayName & "';'" & ContactItem.Email1Address & "';"
Next ContactItem
Me.Contact_Select_List.RowSource = "Full Name;Display Name;E-Mail;" & List
Regards
IC