Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send information to Outlook Adress Book

Status
Not open for further replies.

JPG77

Programmer
Mar 22, 2002
27
FR
Hi,
Does anybody know how to send a record from a VFP6 file in the Outlook Adress Book (Name and telephone number) ?
I know i can extact my informations in a CSV format and then import them from Outlook. But this is not automatic.
Thanks for any suggestion.
Jean-Paul
 
JPG77

You need to substitute [] with the relevant fields from your VFP table.

LOCAL oNameSpace, oContact

#DEFINE olContactItem 2

IF VARTYPE(oOutlook) # [O]
[tab]oOutlook = CreateObject([Outlook.Application])
ENDIF

oNameSpace = oOutlook.GetNameSpace([MAPI])
oContact = oOutlook.CreateItem(olContactItem)

WITH oContact
[tab].FullName = []
[tab].CompanyName = []
[tab].BusinessAddressStreet = []
[tab].BusinessAddressCity = []
[tab].BusinessAddressState = []
[tab].BusinessAddressPostalCode = []
[tab].BusinessAddressCountry = []
[tab].SelectedMailingAddress = []
[tab].BusinessTelephoneNumber = []
[tab].PrimaryTelephoneNumber = []
[tab].BusinessFaxNumber = []
[tab].Save()
ENDWITH

HTH

Chris [pc2]
 
The sun will shine today !!!
Thanks Chris for this quick and pertinant answer.
 
Chris,
Sorry but I still have a problem :

My data are in TBOOK.DBF
The first field is FULLNAME C(50)
What is the good syntax for :

WITH oContact
.FullName = ????

because I have always this error message :
Code exception OLE IDispatch 4096 Microsoft Outlook - Type mismatch ... String cannot be translate...
Thanks for your help.

Jean-Paul
 
This is exactely the code I used and I got the error message.

So Maybe the wrong syntax is in another line but I copy/paste your code.
I'll try line by line.
Thanks anyway.

Jean-Paul
 
Jean-Paul

Remove the .SelectedMailingAddress = [] if you are using it - I assumed you would not want to use it from your first post, but if it's there that will cause the error you describe.
HTH

Chris [pc2]
 
This is fine for the accessing the contacts. How do you access the name and phone number in the personal/global address book?

Thanks
 
Jean-Paul

Assuming it's working now, you could replace .SelectedMailingAddress = ??? with one of the following:-

#DEFINE olNone 0
#DEFINE olHome 1
#DEFINE olBusiness 2
#DEFINE olOther 3

This determines which address Outlook selects.

rsjax1

Not too sure what you mean by "personal/global address book"? HTH

Chris [pc2]
 
I am trying to access the phone number and company from the Global Address book in Outlook. The code you have pulls the fields from the Contacts file (olContactItem). Is there any way to get these fields from the address book?

Thanks
Ron
 
Ron

I stand to be corrected on this but AFIK Outlook only has the one Address book containing Contacts.

You can create Groups which are effectively subsets of Contacts and you can import from other Windows sources into Contacts.

If you open Outlook, how and where do you access your Global Address book? HTH

Chris [pc2]
 
In outlook, when I click on the Address book icon, the display "Show names from the:" field is defaulted to Global Address List. If I drop down the list, I can select Outlook Address book, Contacts or Personal Address book too. I am part of a corporate Email system with multiple facilities and the Global Address List may be an extension of the Outlook Address book. It seems that anything I try, pulls from my Contacts file only.

Ron
 
Ron

"I am part of a corporate Email system with multiple facilities and the Global Address List may be an extension of the Outlook Address book"

I only have Outlook 2000 so therein lies the difference.

Do you have access to the object model for the version you describe? HTH

Chris [pc2]
 
I'm using Outlook 2000 also. However, the Exchange server is not located here at my facility. There is much that is locked down and this may be something that I am unable to get to.

When I hack at it with VB, I can get to the entries in this book with the AddressList and AddressEntry objects and methods, but it is only the name and the email address. I'm looking for the phone number and the company field.

Thanks for your time.
Ron
 
Chris,

Can you look at the post "Outlook Global Address Books", thread 184-77545.

This is the same problem I am trying to explain. The example they have placed there works for me, to pull the manager name, but phone number and company are not available.

Thanks
Ron
 
Ron

As my version of Outlook does not support a Global Address Book, can't be of much use.

You could try posting your question at UT.

I have seen Tamar E. Granor, a co-author of "Microsoft Office Automation with Visul Foxpro" post there on occasion. HTH

Chris [pc2]
 
No problem. I will try that.

Thank you for your time.
Ron
 
IIRC, the Outlook 2K OM doesnt expose what you're after. You'll need to use either MAM, CDO, ADSI, or a 3rd party utility.

There are numerous examples in the MSDN on the former three. Of course, they're all VB, VBA, etc...


Bare in mind, you have to have the necessary privledges to modify the Exchange GAL. Jon Hawkins
 
I have been able to add contacts from access to outlook, however when I use the save event it doesn't replace the previous contact. The code used is below.
Does anyone know how to update or overwrite contacts rather than duplicate?

WITH oContact
.FullName = []
.CompanyName = []
.BusinessAddressStreet = []
.BusinessAddressCity = []
.BusinessAddressState = []
.BusinessAddressPostalCode = []
.BusinessAddressCountry = []
.SelectedMailingAddress = []
.BusinessTelephoneNumber = []
.PrimaryTelephoneNumber = []
.BusinessFaxNumber = []
.Save()
ENDWITH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top