Hello !
Its getting really difficult for me to get this....
Code:
Dim objoutlk As New Outlook.Application
Dim fol As Outlook.mapiFolder
Dim mapises As MAPI.Session
Dim contact As Outlook.ContactItem
Dim ns As Outlook.NameSpace
Dim var1 As String
Private Const cdoPR_GIVEN_NAME As Long = &H3A06001E
Private Const cdoPR_SURNAME As Long = &H3A11001E
Private Const cdoPR_EMAIL As Long = &H39FE001E
Private Sub Form_Load()
Set ns = objoutlk.GetNamespace("MApi")
Set fol = ns.GetDefaultFolder(olFolderContacts)
Me.Show
For Each contact In fol.Items
List1.AddItem contact.FirstName & " , " & contact.LastName
Next
Set mapises = CreateObject("MAPI.session")
mapises.Logon "", "", False, False
gal
Set ns = Nothing
Set objoutlk = Nothing
Set fol = Nothing
End Sub
Public Sub gal()
Dim oAEntries As AddressEntries
Dim oAEntry As AddressEntry
Dim oFields As Field
Dim i As Integer
Dim ii As Integer
Dim iii As Integer
Dim vDetails As Variant
On Error GoTo errorfun
Set oAEntries = mapises.AddressLists.Item("Global Address List").AddressEntries
For i = 1 To oAEntries.Count
Set oAEntry = oAEntries.Item(i)
var1 = ""
For ii = 1 To oAEntry.Fields.Count
Set oFields = oAEntry.Fields(ii)
vDetails = oFields.Value
If oFields.ID = cdoPR_SURNAME Then
var1 = var1 & vDetails & " , "
ElseIf oFields.ID = cdoPR_GIVEN_NAME Then
var1 = var1 & vDetails
MsgBox var1
List1.AddItem var1
End If
Next
Next
errorfun:
gal
End Sub
I am able to get firstname and lastname of all the contacts in a listbox.
I want email ids of all of them.
I am taking lastname,firstname in one column... Is there any way i can get emailid of all these in second column(which will be hidden).