Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;-------------------------------------------------------------------------------------------------------------------------- ; Define UDF to handle all phone number entry formats ;-------------------------------------------------------------------------------------------------------------------------- #DefineFunction CheckPhoneNum( thiscontact, phonenumber, type) IntControl(73,2,0,0,0) RawNum = thiscontact.%type% ; Get phone number from OL contacts formatted IntNum=StrClean (RawNum,"+1234567890","",@FALSE,2) ; Clean to international phone number string IntPf=StrSub(IntNum,1,1); Determine if an international number If IntPf=="+" IntNum=StrSub(IntNum,4,-1) ; Strip international prefix endif If phonenumber == IntNum ; Check phone number & display if found return @true endif return @false :WBERRORHANDLER IntControl(73,2,0,0,0) Error=LastError() line = StrCat("LastError Value is",@TAB,Error,@CRLF) line = StrCat(line,"LastError String is",@TAB,IntControl(34,Error,0,0,0),@CRLF) line = StrCat(line,"LastError Line is",@TAB,wberrorhandlerline,@CRLF) ;Message("Error Info",line) return #EndFunction ;-------------------------------------------------------------------------------------------------------------------------- ; Define all Outlook contact phone number fields to check for a phone number match ;-------------------------------------------------------------------------------------------------------------------------- typelist = StrCat("BusinessFaxNumber",@tab,"BusinessTelephoneNumber",@tab) typelist = StrCat(typelist,"HomeTelephoneNumber",@tab) typelist = StrCat(typelist,"MobileTelephoneNumber",@tab) typecount = ItemCount(typelist,@tab) PhoNum = "2065551212" ;-------------------------------------------------------------------------------------------------------------------------- ; Connect to Outlook contacts folders and search ;-------------------------------------------------------------------------------------------------------------------------- olFolderContacts = 10 objOutlook = ObjectOpen("Outlook.application") objNameSpace = objOutlook.GetNameSpace("MAPI") objFolder = objNameSpace.GetDefaultFolder(olFolderContacts) ContactItems = objFolder.Items Count = ContactItems.count flag = 0 data = "" ; Scan through all contacts For xx = 1 to count thisContact = ContactItems.item(xx) ;check all types For yy = 1 to typecount type = ItemExtract(yy,typelist,@tab) if CheckPhoneNum( thiscontact, PhoNum, type) flag=flag+1 singlecontact = thiscontact ; assign "thiscontact" variable value to "singlecontact" ;assemble comma delimied list of contact names company=thiscontact.CompanyName name=thiscontact.FullName data = StrCat(data,",",name," : ",company) endif Next Next ;if z == 1 then x = "0" ; Set x to zero if Pop Name Only (pno) command line switch used ;;;;;;;;;;;;;;; UNDEFINED Switch flag case 0 ;do nothing break case 1 ; Handle number match in single contact record ;DDELink (name) ;;;;;;;;;;;;;;; Undefined UDF singlecontact.display ; Display the contact break case flag ; Handle number match in multiple contact records data = StrSub(data,2,-1) aname=AskItemList( "Contact Records for - %PhoNum% - Select to display",data,",", @unsorted, @single ) ;DDELink (name) ;;;;;;;;;;;;;;; Undefined UDF name = StrTrim(ItemExtract(1,aname,":")); Use StrTrim to remove leading or trailing spaces findstr = StrCat("[Full Name] = '",name,"'") ;Use quotes around value !!!!! thiscontact = ContactItems.Find(findstr) While thiscontact != 0 thiscontact.display ;Display the contact thiscontact = ContactItems.FindNext EndWhile break EndSwitch ; Clean up ObjectClose(singlecontact) ObjectClose(thiscontact) ObjectClose(ContactItems) ObjectClose(objFolder) ObjectClose(objNameSpace) ObjectClose(objOutlook) exit
Article ID: W16584
File Created: 2005:02:18:12:21:32
Last Updated: 2005:02:18:12:21:32