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.
Printable View
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:Quote:
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.
VB Code:
Private Sub Command1_Click() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim objAL As Outlook.AddressList Dim objAE As Outlook.AddressEntries Dim obj As Object Dim objContact As Outlook.ContactItem Dim objContactFolder As Outlook.MAPIFolder Set objOL = Outlook.Application Set objNS = objOL.GetNamespace("MAPI") Set objContactFolder = objNS.GetDefaultFolder(olFolderContacts) Dim i As Integer For Each obj In objContactFolder.Items If obj.Class <> 69 Then rtb1.Text = rtb1.Text & obj.FirstName & " " & obj.LastName & " : " & obj.Email1Address & vbCrLf End If Next Set objOL = Nothing Set objNS = Nothing Set objAL = Nothing Set objAE = Nothing End Sub
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:
'Set A Reference to the Microsoft Outlook Object Library Private olApp As Outlook.Application Private olNS As Outlook.NameSpace Private olAL As Outlook.AddressList Private olAE As Outlook.AddressEntry Private olMail As Outlook.MailItem Private Sub Form_Load() Dim Counter As Long Set olApp = New Outlook.Application Set olNS = olApp.GetNamespace("MAPI") For Each olAL In olNS.AddressLists For Each olAE In olAL.AddressEntries DoEvents Counter = Counter + 1 Label1.Caption = Counter ListView1.ListItems.Add , , olAE.Name ListView1.ListItems(ListView1.ListItems.Count).SubItems(1) = olAE.Address Next Next 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:
MAPISession1.SignOn With MAPIMessages1 .SessionID = MAPISession1.SessionID .Compose .RecipAddress = "[email protected]" .ResolveName .AddressResolveUI = True .MsgSubject = "My Subject" .MsgNoteText = "My body" .AttachmentIndex = 0 .AttachmentPosition = 0 .AttachmentPathName = "c:\temp\test.txt" .Send End With MAPISession1.SignOff