Microsoft KB Archive/179082

= How To Read Address Book Properties from Active Server Pages (ASP) Page with VBScript =

Article ID: 179082

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Collaboration Data Objects 1.21
 * Microsoft Collaboration Data Objects 1.2

-



This article was previously published under Q179082



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" %>

    Document Title  

<%   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 & " ") Response.Write("E-address: " & objAddressEntry.Address & " ") Response.Write("Given Name: " & _               objAddressEntry.Fields(CdoPR_GIVEN_NAME).Value  & " ") Response.Write("Initials: " & _               objAddressEntry.Fields(CdoPR_INITIA).Value  & " ") Response.Write("Surname: " & _               objAddressEntry.Fields(cdoPR_SURNAME).Value  & " ") Response.Write("Display Name: " & _               objAddressEntry.Fields(CdoPR_DISPLAY_NAME).Value  & " ") Response.Write("Alias: " & _               objAddressEntry.Fields(CdoPR_ACCOUNT).Value  & " ") Response.Write("Title: " & _               objAddressEntry.Fields(CdoPR_TITLE).Value  & " ") Response.Write("Company Name: " & _               objAddressEntry.Fields(cdoPR_COMPANY_NAME).Value & " ") Response.Write("Office Location: " & _               objAddressEntry.Fields(CdoPR_OFFICE_LOCATION).Value & _                " ") Response.Write("Office Phone 1: " & _               objAddressEntry.Fields _                (CdoPR_OFFICE_TELEPHONE_NUMBER).Value & " ") Response.Write("Office Phone 2: " & _               objAddressEntry.Fields _                (CdoPR_OFFICE2_TELEPHONE_NUMBER).Value & " ") Response.Write("Business Fax: " & _               objAddressEntry.Fields _                (CdoPR_BUSINESS_FAX_NUMBER).Value  & " ") Response.Write("Mobile Phone: " & _               objAddressEntry.Fields _                (CdoPR_MOBILE_TELEPHONE_NUMBER).Value  & " ") Response.Write("Pager: " & _               objAddressEntry.Fields _                (CdoPR_PAGER_TELEPHONE_NUMBER).Value  & " ") Response.Write("Assistant: " & _               objAddressEntry.Fields(CdoPR_ASSISTANT).Value  & " ") Response.Write("Assistant Phone: " & _               objAddressEntry.Fields _                (CdoPR_ASSISTANT_TELEPHONE_NUMBER).Value  & " ") Response.Write("Home Phone 1: " & _               objAddressEntry.Fields _                (CdoPR_HOME_TELEPHONE_NUMBER).Value  & " ") Response.Write("Home Phone 2: " & _               objAddressEntry.Fields _                (CdoPR_HOME2_TELEPHONE_NUMBER).Value  & " ") Response.Write("Home Fax: " & _               objAddressEntry.Fields _                (CdoPR_HOME_FAX_NUMBER).Value  & " ") Response.Write("Home Street: " & _               objAddressEntry.Fields _                (CdoPR_HOME_ADDRESS_STREET).Value  & " ") Response.Write("Home City: " & _               objAddressEntry.Fields _                (CdoPR_HOME_ADDRESS_CITY).Value  & " ") Response.Write("Home State: " & _               objAddressEntry.Fields _                (CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE).Value  & " ") Response.Write("Home Postal Code: " & _               objAddressEntry.Fields _                (CdoPR_HOME_ADDRESS_POSTAL_CODE).Value  & " ") Response.Write("Home Country: " & _               objAddressEntry.Fields _                (CdoPR_HOME_ADDRESS_COUNTRY).Value  & " ") Response.Write("Manager Name: " & _               objAddressEntry.Fields(CdoPR_MANAGER_NAME).Value  & " ") Response.Write("Manager Name: " & _               objAddressEntry.Manager & "  ") Next

objSession.Logoff Set objFilter = Nothing Set objAddrEntries= Nothing Set objSession = Nothing

%>

 

Additional query words: ActMsg

Keywords: kbhowto kbinetdev kbfaq KB179082

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.