Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Outlook address book
Message
De
12/09/2003 15:22:34
 
 
À
12/09/2003 14:58:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00828632
Message ID:
00828646
Vues:
18
>I would like to use the Outlook address book to develop special lists that will be stored in a table with an application. A process that was developed by someone else has hard-coded lists that are used to send email when the process runs to notify users of the status of the process. I would like to make these lists dynamic in the table by selecting the names using the Outlook address book so manual changes are not required.
>
>Can you suggest how this might be done.

You can use Automation to read the Outlook address book. It's hard to recommend anything specific without knowing more about how you want to this work, but here's an example from the book Della Martin and I wrote ("Microsoft Office Automation with Visual FoxPro") that reads the Contacts folder:
* MakeContactList.PRG
* © 2000, Tamar E. Granor and Della Martin
* From:  Microsoft Office Automation with Visual FoxPro
* Hentzenwerke Publishing. www.hentzenwerke.com

* Read Outlook contact information into a cursor
#DEFINE olContacts 10
#DEFINE olNone 0
#DEFINE olHome 1
#DEFINE olBusiness 2
#DEFINE olOther 3

LOCAL oNameSpace, oContacts, oContact
LOCAL cFirst, cLast, cAddr, cPhone

IF VarType(oOutlook) <> "O"
	* Start or connect to Outlook
	* Make it public for demonstration purposes.
	RELEASE oOutlook
	PUBLIC oOutlook
	oOutlook = CreateObject("Outlook.Application")
ENDIF
oNameSpace = oOutlook.GetNameSpace("MAPI")

* Get Contacts folder
oContacts= oNameSpace.GetDefaultFolder( olContacts )

* Create a cursor to hold contact information
CREATE CURSOR ContactInfo ;
   (cFirstName C(15), cLastName C(20), mAddress M, cPhoneNum C(30))
   
* Go through contacts
FOR EACH oContact IN oContacts.Items
	WITH oContact
		cFirst = .FirstName
		cLast = .LastName
		cPhone = .PrimaryTelephoneNumber   
		
		* Choose the right address. If the primary phone number is empty,
		* pick up the phone number associated with this address.
		DO CASE
		CASE .SelectedMailingAddress = olHome
			cAddr = .HomeAddress
			IF EMPTY(cPhone)
				cPhone = .HomeTelephoneNumber
			ENDIF
		CASE .SelectedMailingAddress = olBusiness
			cAddr = .BusinessAddress
			IF EMPTY(cPhone)
				cPhone = .BusinessTelephoneNumber
			ENDIF
		CASE .SelectedMailingAddress = olOther
			cAddr = .OtherAddress
			IF EMPTY(cPhone)
				cPhone = .OtherTelephoneNumber
			ENDIF
		CASE .SelectedMailingAddress = olNone
			cAddr = ""
		ENDCASE
		
		INSERT INTO ContactInfo VALUES (cFirst, cLast, cAddr, cPhone)
	ENDWITH
ENDFOR

* Show the results
BROWSE

RETURN
Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform