Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Troy Reganall
  Where is Troy Reganall?
 Toledo (OH)
 Ohio - United States
 Troy Reganall
 To: Yuri Rubinov
  Where is Yuri Rubinov?
 Philadelphia
 Pennsylvania - United States
 Yuri Rubinov
 Tags
Subject: RE: Update Contacts from a DBF
Thread ID: 112552 Message ID: 112579 # Views: 1 # Ratings: 0
Version: Visual FoxPro 8 Category: Microsoft Office Automation
Date: Thursday, November 09, 2006 8:16:14 PM         
   


> > Hi everyone,
> >
> > Anyone have any code to update the contacts in MS Outlook from a dbf file?
> >
> > Troy
> > Long Live FoxPro!

>
> Something like this:
>
oOlApp = CreateObject("Outlook.Application") && Open Outlook
> with oOlApp.GetNameSpace("MAPI").GetDefaultFolder(10)	&& 10 = Default contacts folder	 
> 
> 	FOR i = 1 TO .Items.Count		&& modify
> 		.Items(i).LastName= "NEWNAME"
> 		.....
> 	endfor
> 
> 	with .Items.Add			&& add new contact
> 		.LastName= "Troy from Toledo"
>                 ....
> 	endwith
> endwith
> .....

> Best Wishes,
>
> Yuri Rubinov


Thanks for the replies. I did not know about that import feature Koen, I'll have to give that a try sometime. However, Yuri got me heading in the direction I was looking for. With some modification I got this to work. The key to completing the add was to make sure you have .save property at the end. It took me a while to figure that out (haha). Here is my code.
***************************
oOlApp = CreateObject("Outlook.Application") && Open Outlook
with oOlApp.GetNameSpace("MAPI").GetDefaultFolder(10)	&& 10 = Default contacts folder	 

select 1
use mytable
go top
do while eof()=.F.

if !empty(msoutlook)

   with .Items.Add
      .fullname = allt(a->last_name)+', '+allt(a->first_name)
      .fileas = allt(a->last_name)+', '+allt(a->first_name)
      .BusinessAddressStreet = allt(a->address)
      .BusinessAddressCity = allt(a->city)
      .BusinessAddressState = allt(a->state)
      .BusinessAddressPostalCode = allt(a->zip)
      .BusinessAddressCountry = "United States"
      .BusinessTelephoneNumber = allt(a->bus_phone)
      .HomeTelephoneNumber = allt(a->home_phone)
      .Email1Address = allt(a->email)
      .WebPage = allt(a->weburl)
      .save
    endwith
	
endif

skip 1
Enddo

endwith

Release oOlApp
*****************************

Troy
Long Live FoxPro!

ENTIRE THREAD

Update Contacts from a DBF Posted by Troy Reganall @ 11/9/2006 3:34:09 PM
RE: Update Contacts from a DBF Posted by Koen Piller @ 11/9/2006 4:06:08 PM
RE: Update Contacts from a DBF Posted by Yuri Rubinov @ 11/9/2006 4:29:19 PM
RE: Update Contacts from a DBF Posted by Troy Reganall @ 11/9/2006 8:16:14 PM
RE: Update Contacts from a DBF Posted by Ken Murphy @ 11/9/2006 9:09:44 PM
RE: Update Contacts from a DBF Posted by Troy Reganall @ 11/10/2006 12:24:44 AM
RE: Update Contacts from a DBF Posted by Ken Murphy @ 11/10/2006 1:23:10 AM
RE: Update Contacts from a DBF Posted by Simon Arnold @ 11/10/2006 3:12:49 PM