General information
Category:
Object Oriented Programming
Hi Matt,
Thanks very much. You've done excellent job. Your code is just what I was after. i modified it though to search for Contacts in Public Folders and extract the data which has mobile No. in MobileTelephoneNumber field.
Q.
When I am cycling through contacts it takes time to extract those data. Around 40 sec for ~800 contacts.
Is there a way i can speed things up a bit?
See my modified code
CLEA
CLOS ALL
CLEAR ALL
RELEASE ALL
*--6-28-2001-MPL: Create Outlook
loOutlook = CREATEOBJECT('Outlook.Application')
loNameSpace = loOutlook.GetNameSpace('MAPI')
CREATE CURSOR Outlookfolders( folderid c(10), folderlevel N(3),foldername c(50),parentfolder c(10))
CREATE CURSOR PacomContacts( LASTNAME c(20), FIRSTNAME c(20), MOBILE c(20))
*--6-28-2001-MPL: Start with the NameSpace and Get all SubFolders inside it.
GetSubFolders(loNameSpace,1,'Top Level')
SELE lastname,firstname,allt(mobile) as Mobile FROM PacomContacts ORDER BY LASTNAME,FIRSTNAME where substr(mobile,1,4)<>'0011' INTO CURSOR PacomContacts
BROW
FUNCTION GetSubFolders(toCurrentFolder,tnLevel,tcParentID)
LOCAL toCurrentFolder,tnLevel,tcParentID,i, j, lctabvar
lctabvar = space(4*tnLevel)
FOR i = 1 TO toCurrentFolder.folders().COUNT
lcNextID = GetNextId('OutlookFolders')
loContacts = toCurrentFolder.folders(i)
IF loContacts.NAME = 'Pacom-Bell Contacts'
wait window 'Found ' + allt(str(loContacts.items.COUNT)) + ' contacts in '+loContacts.NAME + ' folder ' timeout 2
ContactsMob = 0
FOR j = 1 TO loContacts.items.COUNT
IF !EMPTY(loContacts.items.ITEM[j].MobileTelephoneNumber)
ContactsMob = ContactsMob + 1
wait window 'Total contacts with Mobile No.s ' + allt(str(ContactsMob)) nowait
*?loContacts.items.ITEM[j].FIRSTNAME + ' ' +;
* loContacts.items.ITEM[j].LASTNAME +' '+ loContacts.items.ITEM[j].MobileTelephoneNumber
INSERT INTO PacomContacts VALUES (loContacts.items.ITEM[j].LASTNAME,loContacts.items.ITEM[j].FIRSTNAME,;
loContacts.items.ITEM[j].MobileTelephoneNumber)
ENDIF
ENDFOR
wait window 'Total contacts with Mobile No.s ' + allt(str(ContactsMob)) + ' in '+loContacts.NAME + ' folder '
exit
ENDIF
*--6-28-2001-MPL: Call the function recursively to get the subfolders for the current folder..
GetSubFolders(toCurrentFolder.folders(i),tnLevel+1,lcNextID)
ENDFOR
RETURN
ENDFUNC GetSubFolders
FUNCTION GetNextId(tcAlias)
SELECT MAX(VAL(folderid)) AS RecId FROM (tcAlias) INTO CURSOR Tada
PRIVATE lcNextID
lcNextID = PADL(ALLTRIM(STR(Tada.RecId + 1)),10,'0')
USE IN Tada
RETURN lcNextID
ENDFUNC GetNextId
Regards
Dejan
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only