Results 1 to 3 of 3

Thread: Outlook Address Control

  1. #1

    Thread Starter
    Addicted Member AmmerBow's Avatar
    Join Date
    Sep 2000
    Posts
    195

    Outlook Address Control

    Is there a way to use the ms outlook address list control in my program.

    Just like the common control box for loading files is used in all applications. I need the same control that displays the address list inside of outlook.
    Amiga 500 was here.

  2. #2
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Re: Outlook Address Control

    Originally posted by AmmerBow
    Is there a way to use the ms outlook address list control in my program.

    Just like the common control box for loading files is used in all applications. I need the same control that displays the address list inside of outlook.
    you can do it with a ref to Outlook:

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim objOL As Outlook.Application
    3.     Dim objNS As Outlook.NameSpace
    4.     Dim objAL As Outlook.AddressList
    5.     Dim objAE As Outlook.AddressEntries
    6.     Dim obj As Object
    7.    
    8.     Dim objContact As Outlook.ContactItem
    9.     Dim objContactFolder As Outlook.MAPIFolder
    10.    
    11.     Set objOL = Outlook.Application
    12.     Set objNS = objOL.GetNamespace("MAPI")
    13.  
    14.    
    15.     Set objContactFolder = objNS.GetDefaultFolder(olFolderContacts)
    16.    
    17.     Dim i As Integer
    18.     For Each obj In objContactFolder.Items
    19.     If obj.Class <> 69 Then
    20.         rtb1.Text = rtb1.Text & obj.FirstName & " " & obj.LastName & " : " & obj.Email1Address & vbCrLf
    21.     End If
    22.     Next
    23.    
    24.     Set objOL = Nothing
    25.     Set objNS = Nothing
    26.     Set objAL = Nothing
    27.     Set objAE = Nothing
    28. End Sub

  3. #3
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    That looks in your Contact folder - which might be what you want. Or else you can use the Global Address List from Exchange:

    Find address in GAL:
    VB Code:
    1. 'Set A Reference to the Microsoft Outlook Object Library
    2. Private olApp As Outlook.Application
    3. Private olNS As Outlook.NameSpace
    4. Private olAL As Outlook.AddressList
    5. Private olAE As Outlook.AddressEntry
    6. Private olMail As Outlook.MailItem
    7.  
    8. Private Sub Form_Load()
    9. Dim Counter As Long
    10. Set olApp = New Outlook.Application
    11.   Set olNS = olApp.GetNamespace("MAPI")
    12.   For Each olAL In olNS.AddressLists
    13.     For Each olAE In olAL.AddressEntries
    14.       DoEvents
    15.       Counter = Counter + 1
    16.       Label1.Caption = Counter
    17.       ListView1.ListItems.Add , , olAE.Name
    18.       ListView1.ListItems(ListView1.ListItems.Count).SubItems(1) = olAE.Address
    19.     Next
    20.   Next
    21. End Sub

    Or else you can use the normal name resolution:

    Put a Microsoft MAPI Session and MAPI Messages control on the form:
    VB Code:
    1. MAPISession1.SignOn
    2. With MAPIMessages1
    3.         .SessionID = MAPISession1.SessionID
    4.         .Compose
    5.         .RecipAddress = "[email protected]"
    6.         .ResolveName
    7.                  .AddressResolveUI = True
    8.  
    9.         .MsgSubject = "My Subject"
    10.         .MsgNoteText = "My body"
    11.         .AttachmentIndex = 0
    12.         .AttachmentPosition = 0
    13.         .AttachmentPathName = "c:\temp\test.txt"
    14.         .Send
    15. End With
    16. MAPISession1.SignOff

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