HOWTO: Read Address Book Properties from Active Server Pages (ASP) Page with VBScript
ID: Q179082
|
The information in this article applies to:
-
Collaboration Data Objects (CDO), versions 1.2, 1.21
SUMMARY
This article provides an example of how to use VBScript to retrieve some of
the more common fields available in the address book to an Active Server
Pages (ASP) page. This article also shows how to use a filter on the
address book.
MORE INFORMATION
Copy and paste the following code to an ASP file:
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html;charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<%
CONST strServer = "MyServer"
CONST strMailbox = "MyMailbox"
CONST CdoPR_GIVEN_NAME = &H3A06001E 'First Name
CONST CdoPR_INITIALS = &H3A0A001E 'Initials
CONST CdoPR_SURNAME = &H3A11001E 'Last Name
CONST CdoPR_DISPLAY_NAME = &H3001001E 'Display Name
CONST CdoPR_ACCOUNT = &H3A00001E 'Alias
CONST CdoPR_TITLE = &H3A17001E 'Title
CONST CdoPR_COMPANY_NAME = &H3A16001E 'Company
CONST CdoPR_OFFICE_LOCATION = &H3A19001E 'Office
CONST CdoPR_HOME_TELEPHONE_NUMBER = &H3A09001E 'Phone
CONST CdoPR_HOME2_TELEPHONE_NUMBER = &H3A2F001E 'Home Phone 2
CONST CdoPR_HOME_FAX_NUMBER = &H3A25001E 'Home Fax
CONST CdoPR_HOME_ADDRESS_STREET = &H3A5D001E 'Address
CONST CdoPR_HOME_ADDRESS_CITY = &H3A59001E 'City
CONST CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE = &H3A5C001E 'State
CONST CdoPR_HOME_ADDRESS_POSTAL_CODE = &H3A5B001E 'Zip
CONST CdoPR_HOME_ADDRESS_COUNTRY = &H3A5A001E 'Country
CONST CdoPR_MANAGER_NAME = &H3A4E001E 'Manager
CONST CdoPR_OFFICE_TELEPHONE_NUMBER = &H3A08001E 'Business
'Phone
CONST CdoPR_OFFICE2_TELEPHONE_NUMBER = &H3A1B001E 'Business
'Phone 2
CONST CdoPR_BUSINESS_FAX_NUMBER = &H3A24001E 'Fax
CONST CdoPR_ASSISTANT = &H3A30001E 'Assistant
CONST CdoPR_ASSISTANT_TELEPHONE_NUMBER = &H3A2E001E 'Asistant
'Phone Number
CONST CdoPR_MOBILE_TELEPHONE_NUMBER = &H3A1C001E 'Mobile
CONST CdoPR_PAGER_TELEPHONE_NUMBER = &H3A21001E 'Pager
Dim objSession
Dim objAddrEntries
Dim objAddressEntry
Dim objFilter
Dim strProfileInfo
strProfileInfo = strServer & vbLf & strMailbox
Set objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False, , True, strProfileInfo
Set objAddrEntries = objSession.AddressLists _
("Global Address List").AddressEntries
'Create a filter for a user.
Set objFilter = objAddrEntries.Filter
objFilter.Fields.Add cdoPR_SURNAME, "LastName"
objFilter.Fields.Add CdoPR_GIVEN_NAME, "FirstName"
On Error Resume Next 'Required, because, if an item is missing, an
'error returns that stops the process.
For Each objAddressEntry In objAddrEntries
Response.Write(objAddressEntry.Name & "<br>")
Response.Write("E-address: " & objAddressEntry.Address & "<br>")
Response.Write("Given Name: " & _
objAddressEntry.Fields(CdoPR_GIVEN_NAME).Value & "<br>")
Response.Write("Initials: " & _
objAddressEntry.Fields(CdoPR_INITIA).Value & "<br>")
Response.Write("Surname: " & _
objAddressEntry.Fields(cdoPR_SURNAME).Value & "<br>")
Response.Write("Display Name: " & _
objAddressEntry.Fields(CdoPR_DISPLAY_NAME).Value & "<br>")
Response.Write("Alias: " & _
objAddressEntry.Fields(CdoPR_ACCOUNT).Value & "<br>")
Response.Write("Title: " & _
objAddressEntry.Fields(CdoPR_TITLE).Value & "<br>")
Response.Write("Company Name: " & _
objAddressEntry.Fields(cdoPR_COMPANY_NAME).Value & "<br>")
Response.Write("Office Location: " & _
objAddressEntry.Fields(CdoPR_OFFICE_LOCATION).Value & _
"<br>")
Response.Write("Office Phone 1: " & _
objAddressEntry.Fields _
(CdoPR_OFFICE_TELEPHONE_NUMBER).Value & "<br>")
Response.Write("Office Phone 2: " & _
objAddressEntry.Fields _
(CdoPR_OFFICE2_TELEPHONE_NUMBER).Value & "<br>")
Response.Write("Business Fax: " & _
objAddressEntry.Fields _
(CdoPR_BUSINESS_FAX_NUMBER).Value & "<br>")
Response.Write("Mobile Phone: " & _
objAddressEntry.Fields _
(CdoPR_MOBILE_TELEPHONE_NUMBER).Value & "<br>")
Response.Write("Pager: " & _
objAddressEntry.Fields _
(CdoPR_PAGER_TELEPHONE_NUMBER).Value & "<br>")
Response.Write("Assistant: " & _
objAddressEntry.Fields(CdoPR_ASSISTANT).Value & "<br>")
Response.Write("Assistant Phone: " & _
objAddressEntry.Fields _
(CdoPR_ASSISTANT_TELEPHONE_NUMBER).Value & "<br>")
Response.Write("Home Phone 1: " & _
objAddressEntry.Fields _
(CdoPR_HOME_TELEPHONE_NUMBER).Value & "<br>")
Response.Write("Home Phone 2: " & _
objAddressEntry.Fields _
(CdoPR_HOME2_TELEPHONE_NUMBER).Value & "<br>")
Response.Write("Home Fax: " & _
objAddressEntry.Fields _
(CdoPR_HOME_FAX_NUMBER).Value & "<br>")
Response.Write("Home Street: " & _
objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_STREET).Value & "<br>")
Response.Write("Home City: " & _
objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_CITY).Value & "<br>")
Response.Write("Home State: " & _
objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE).Value & "<br>")
Response.Write("Home Postal Code: " & _
objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_POSTAL_CODE).Value & "<br>")
Response.Write("Home Country: " & _
objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_COUNTRY).Value & "<br>")
Response.Write("Manager Name: " & _
objAddressEntry.Fields(CdoPR_MANAGER_NAME).Value & "<br>")
Response.Write("Manager Name: " & _
objAddressEntry.Manager & "<br><br>")
Next
objSession.Logoff
Set objFilter = Nothing
Set objAddrEntries= Nothing
Set objSession = Nothing
%>
</BODY>
</HTML>
Additional query words:
ActMsg
Keywords : kbASP kbCDO120 kbCDO121 kbVBScript kbfaq kbInetDev
Version : WINDOWS:1.2,1.21
Platform : WINDOWS
Issue type : kbhowto