Download Address Book

G

Guest

I want to write a macro that downloads full details from the global address
list in the address book. Need some pseudo-code/pointers/codelets that do it.
Pls help!!

Regards,
Bharath Rajamani

--
 
G

Guest

The Outlook Object Model only gives you basic information from any
AddressList object retrieved from the Global Address List. To get the full
info you see in the Properties dialog for an address entry in that list, you
need to use CDO. This macro below will loop through the GAL and print out
the standard properties on every mailbox/remote user that is listed.

If you need a listing of the property tags for the CDO constants used in
this macro, see:

CDO Property Tags Constants Declarations Page:
http://www.outlookexchange.com/articles/home/cdopropertytagconstants.asp

For more info on CDO, see:

Using Collaboration Data Objects (CDO) in Microsoft Outlook and Microsoft
Exchange Programming:
http://www.outlookcode.com/d/cdo.htm

Sub GetGALAddressDetails()
On Error Resume Next

Dim objSession As New MAPI.Session
Dim objAdds As MAPI.AddressLists
Dim objAddress As MAPI.AddressEntry
Dim objGAL As MAPI.AddressList
Dim objFields As MAPI.Fields, objField As MAPI.Field

objSession.Logon , , , False

If objSession Is Nothing Then Exit Sub

Set objAdds = objSession.AddressLists
Set objGAL = objAdds.Item("Global Address List")
For Each objAddress In objGAL.AddressEntries
If objAddress.DisplayType = CdoUser Or objAddress.DisplayType =
CdoRemoteUser Then
If InStr(objAddress.Name, "Eric") > 0 Then
Set objField = objAddress.Fields(CdoPR_BUSINESS_ADDRESS_CITY)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_ADDRESS_COUNTRY)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_ADDRESS_POSTAL_CODE)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_ADDRESS_STATE_OR_PROVINCE)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_ADDRESS_STREET)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_TITLE)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_COMPANY_NAME)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_DEPARTMENT_NAME)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_OFFICE_LOCATION)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_ASSISTANT)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
End If
End If
Next

objSession.Logoff

Set objSession = Nothing
Set objAdds = Nothing
Set objAddress = Nothing
Set objGAL = Nothing
Set objFields = Nothing
Set objField = Nothing
End Sub
 
G

Guest

Thx Eric! I get this error on the macro, would you know why it occurs:

Compiler Error: User-defined type not defined at
Dim objSession As MAPI.Session


Rgds,

--
Manager, International Private Banking, International Banking Group, ICICI
Bank
East Wing 8th floor South, ICICI Towers, Bandra Kurla Complex, Mumbai India
400051
 
G

Guest

In the Outlook VBA Editor, go to Tools - References and select Microsoft CDO
1.21 Library.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top