Get recipients from addressbook (with redemption)

  • Thread starter Thread starter Eddy d'Artois via OfficeKB.com
  • Start date Start date
E

Eddy d'Artois via OfficeKB.com

I'm writing a access2000 program where I let the user pick persons from the
outlook 2000 addressbook. I managed to do so, but I got the security
warning, so I discovered Outlook Redemption. I'm not so used both
programming in Outlook as well as using Redemption .

Can anybody help me to complete the following code ?

Private Sub cmdPickAddress_Click()
Dim CdoSession As MAPI.Session
Dim objReUtil

Set CdoSession = CreateObject("MAPI.Session")
CdoSession.Logon "", "", False, False, 0

Set objReUtil = CreateObject("Redemption.MAPIUtils")
objReUtil.AddressBook 'here we get the addressbook to choose the persons
 
MAPIUtils.AddressBook returns an instance of the Recipients collection. You
can then loop through all the items in the collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
I changed the code like that: it works as long as you don't choose from the
contacts folder.
Is there any way to know if the folder was contacts, and in this case take
eg the email1Address from the list in stead of the displayname ???


Dim oRecp As Redemption.SafeRecipient

On Error GoTo HandleErr
Set CdoSession = CreateObject("MAPI.Session")
CdoSession.Logon "", "", False, False, 0

Set objReUtil = CreateObject("Redemption.MAPIUtils")
Set oRecps = objReUtil.AddressBook(Title:="Select Attendees",
forceResolution:=True, _
recipLists:=1, _
toLabel:="&To")
For Each oRecp In oRecps
Debug.Print oRecp.Name
Next
CdoSession.Logoff

ExitHere:
Exit Sub

HandleErr:
Select Case Err.Number
Case 424 'cancel is choosen
Exit Sub
Resume Next
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description,
vbCritical, "Form_Form3.cmdPickAddress_Click"
End Select

End Sub
 
Redemption just returns whatever that particular address entry exposes in
PR_DISPLAY_NAME, it has no idea where it comes from. If you'll look at that
entry in OutlookSpy (click IAddrBook) what do you see?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
The Property tag is PR_OBJECT_TYPE
The get search path shows both Global Address List and Contacts
 
I am not sure what you mean. What does PR_OBJECT_TYPE have to do with it?
Click IAddrBook, then click "Open Root Container", then drill down to that
particular entry from thee GetHierarchyTable/GetContentsTable tabs.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Dimitry,

Thanks for help. The purpose of my question was initially to get all of
the names and e-mail addresses from the users address-book, rather than
storing all these in my application. I thought there would be a problem
with the contacts-folder, but the application works also fine with the
contactsfolder.

I only discovered redemption and Outlookspy last week, so I will need to
practice a bit first with these things. Anyway, the use of redemption in
my application for addressbooks and to send mails made it much more user-
friendly. Thanks once more.

Eddy
 
Back
Top