Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Troy Reganall
  Where is Troy Reganall?
 Toledo (OH)
 Ohio - United States
 Troy Reganall
 Tags
Subject: RE: Update Contacts from a DBF
Thread ID: 112552 Message ID: 112584 # Views: 2 # Ratings: 0
Version: Visual FoxPro 8 Category: Microsoft Office Automation
Date: Thursday, November 09, 2006 9:09:44 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!


Troy,

When you post code, please use the code tags < vfp > Code Goes Here < /vfp > (without the spaces) or select your code and click the code tag button fourth from the left. It makes it a lot easier to read - especially when, like me, age catches up with the eyesight.

I fixed it for you this time,

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

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