WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI LDAP CDO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

CDO Collections and MS Exchange 5.5 Global Address Book

Keywords: 	  Collaborative Data Objects (CDO)  MS Exchange 5.5 Global Address Book

;       script by Jay Alverson, 10/4/2000
;
;       This script uses winbatch and Collaborative Data Objects (CDO)
;       to search the MS Exchange 5.5 Global Address book for certain
;       names, by applying a filter to the query based on a last name
;       or known display name. You can then retrieve user-specific 
;       information from the query. Please note your Exchange Admin
;       might populate the fields below differently from ours.
;
;       There are more fields, but I haven't discovered them all yet,
;       if you do please post them. Feel free to alter the code, our
;       GAL is huge (16,000+ entries) and my application uses display
;       names.
;
;       Also you can use the following list of CdoPR_ vars in your
;       script, just do a search & replace ";debug.print " with NULL
;       and all the field constants will be declared...my example
;       uses the numeric values, which you can change to make it
;       easier to read...
;
;       I'm using winbatch 2000c and CDO.DLL (version 5.5.2448.0,
;       Collaboration Data Objects 1.21 for Windows NT) which you
;       can download from the Microsoft Web Site.
;       
; Reference: http://msdn2.microsoft.com/en-us/library/ms526356(VS.85).aspx
;
;debug.print CdoPR_CUSTOMER_ID_A = 977928222 
;debug.print CdoPR_GIVEN_NAME = 973471774 
;debug.print CdoPR_INITIALS = 973733918 
;debug.print CdoPR_SURNAME = 974192670 
;debug.print CdoPR_DISPLAY_NAME = 805371934 
;debug.print CdoPR_ACCOUNT = 973078558 
;debug.print CdoPR_TITLE = 974585886 
;debug.print CdoPR_COMPANY_NAME = 974520350 
;debug.print CdoPR_OFFICE_LOCATION = 974716958 
;debug.print CdoPR_OFFICE_TELEPHONE_NUMBER = 973602846 
;debug.print CdoPR_OFFICE2_TELEPHONE_NUMBER = 974848030 
;debug.print CdoPR_BUSINESS_FAX_NUMBER = 975437854 
;debug.print CdoPR_MOBILE_TELEPHONE_NUMBER = 974913566 
;debug.print CdoPR_PAGER_TELEPHONE_NUMBER = 975241246 
;debug.print CdoPR_ASSISTANT = 976224286 
;debug.print CdoPR_ASSISTANT_TELEPHONE_NUMBER = 976093214 
;debug.print CdoPR_HOME_TELEPHONE_NUMBER = 973668382 
;debug.print CdoPR_HOME2_TELEPHONE_NUMBER = 976158750 
;debug.print CdoPR_HOME_FAX_NUMBER = 975503390 
;debug.print CdoPR_HOME_ADDRESS_STREET = 979173406 
;debug.print CdoPR_HOME_ADDRESS_CITY = 978911262 
;debug.print CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE = 979107870 
;debug.print CdoPR_HOME_ADDRESS_POSTAL_CODE = 979042334 
;debug.print CdoPR_HOME_ADDRESS_COUNTRY = 978976798 
;debug.print CdoPR_MANAGER_NAME = 978190366 

;       setup the profile to logon to...
strProfileInfo = strcat("profilename", @lf, "servername")
;       open the mapi session object and logon...
cdoSession = Objectopen("MAPI.Session")
cdoSession.Logon( , , @false, @false, , @True, strProfileInfo)
;       set the personal address book object, and its entries...
gal = cdoSession.AddressLists("Global Address List")
galEntries = gal.AddressEntries
galFilter = galEntries.Filter
galFilterFields = galFilter.Fields
;       set the filter to the DISPLAYNAME field...
;galFilterFields.add(805371934, "Alverson Jay W")
;974192670 = SURNAME field...
galFilterFields.add(974192670, "Smith")
;       find out how many items were returned...
entrycount = 0
loopstart = 1
;       loop until no more objects in the collection...
;suppress the minor errors...
errormode(@off)
while @true
        entry = galEntries.item(loopstart)      
        if entry > 0 ; if entry == 0 then there's no object in the collection...
;               since there is one increment...
                loopstart = loopstart + 1
        else
;               no more objects then leave the loop...
                break
        endif
endwhile
;       reset the errormode...
errormode(@cancel)
;       one too many objects so decrement the count...
entrycount = loopstart - 1
;       show how many entries returned by the query...
message("Number of Entries Returned", entrycount)
for loopstart = 1 to entrycount
        entry = galEntries.item(loopstart)
        entryFields = entry.fields(805371934)
        message("Entry #%loopstart% of %entrycount%", entry.name)
        message("Entry #%loopstart% of %entrycount%", entry.address)
        message("Entry #%loopstart% of %entrycount%", entryFields.value)
next

objectclose(cdoSession)

exit



Article ID:   W14663
Filename:   CDO Collections and Global Address Book.txt
File Created: 2008:01:04:10:49:30
Last Updated: 2008:01:04:10:49:30