Results 1 to 6 of 6

Thread: Get emails from address book...

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    11

    Cool

    How can I get a list of all email stored in the outlook address book? I'm going to use this in an axtivex 'tell a friend' control.

    /Niels Bosma

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    'set a reference to outlook in references
    
    Dim moMail As Object
    Dim loNameSpace As Object
    Dim loNameAddresses As Object
    Dim loAddresses As Object
    Dim loAddressList As Object
    
    Set moMail = New Outlook.Application
    Dim moAddresses As Outlook.AddressLists
    
    Set loNameSpace = moMail.GetNamespace("MAPI")
    Set loAddresses = loNameSpace.AddressLists("Contacts")
    
    Set loAddressList = loAddresses.AddressEntries
    List1.Clear
    
     Dim intcre As Integer
    For intcre = 1 To loAddressList.Count
        List1.AddItem loAddressList.Item(intcre).Name
        List1.AddItem loAddressList.Item(intcre).Address
        List1.AddItem "________________________________"
        List1.AddItem ""
    Next intcre
    End Sub
    
    Private Sub List1_Click()
    
    Dim SendMe As String
    SendMe = List1.Text
    ShellExecute hwnd, "open", "mailto:" & SendMe, vbNullString, vbNullString, SW_SHOW
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    11

    Question Reference?

    thanks for the code!, but...

    I can't find Outlook in my reference list. I have outlook express on my computer and the program has to work with both versions !?! Do I have to intall the full office version on outlook?

    /Niels


  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    I don't know for sure but I would think this will only work for Outlook/full version.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    11

    Errros....

    I get runtime error on this line:
    Set loAddresses = loNameSpace.AddressLists("Contacts")

    ('Object could not be found')

    /Niels


  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Are you trying this on a network. If you are, it more than likely won't work because any good network will have their address list on a drive that is not accessable to anyone without superviory or administrative authority.

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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