|
-
Aug 13th, 2002, 04:37 PM
#1
Thread Starter
Junior Member
Extracting Contact info in Outlook 2K
Hi
I'm trying to extract the following contacts info from Outlook 2000
Contact's:
Name
Phone Number
House Address
I can get the contact's name and email with the following code but that is all. I am unsure how to use the Outllok object model so any advice/ examples would be gratefully appreciated
Cheers Norm RC
Private Sub Form_Load()
Dim moMail As Object
Dim loNameSpace As Object
Dim loNameAddresses As Object
Dim loAddresses As Object
Dim loAddressList As Object
Dim intcre As Integer
Dim moAddresses As Outlook.AddressLists
Set moMail = New Outlook.Application
Set loAddressList = loAddresses.AddressEntries
Set loNameSpace = moMail.GetNamespace("MAPI")
Set loAddresses = loNameSpace.AddressLists("Contacts")
With List1
.Clear
For i = 1 To loAddressList.Count
'load the contact info into listbox "List1"
.AddItem loAddressList.Item(i).Name
.AddItem loAddressList.Item(i).Address
Next i
End With
End Sub
-
Aug 13th, 2002, 05:53 PM
#2
Fanatic Member
Here is how I'd do it. Make sure to add a reference to Outlook.
BTW - This should work in 97 or 2000 (for sure 2000)
VB Code:
Dim app As Outlook.Application, MFld As MAPIFolder, nItm As ContactItem
Dim tmpStr As String
Set app = CreateObject("Outlook.Application")
Set MFld = app.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
Open "c:\OLContact.txt" For Output As #1
For Each nItm In MFld.Items
tmpStr = nItm.FullName & vbCrLf & nItm.HomeTelephoneNumber & vbCrLf & nItm.HomeAddress
Print #1, tmpStr & vbCrLf
Next
Close #1
Set nItm = Nothing
Set MFld = Nothing
Set app = Nothing
Shell "notepad c:\OLContact.txt", vbNormalFocus
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|