Results 1 to 2 of 2

Thread: Extracting Contact info in Outlook 2K

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2001
    Posts
    24

    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

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    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:
    1. Dim app As Outlook.Application, MFld As MAPIFolder, nItm As ContactItem
    2. Dim tmpStr As String
    3.  
    4. Set app = CreateObject("Outlook.Application")
    5. Set MFld = app.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
    6.  
    7. Open "c:\OLContact.txt" For Output As #1
    8.     For Each nItm In MFld.Items
    9.         tmpStr = nItm.FullName & vbCrLf & nItm.HomeTelephoneNumber & vbCrLf & nItm.HomeAddress
    10.         Print #1, tmpStr & vbCrLf
    11.     Next
    12. Close #1
    13.  
    14. Set nItm = Nothing
    15. Set MFld = Nothing
    16. Set app = Nothing
    17.  
    18. 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
  •  



Click Here to Expand Forum to Full Width