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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Adding/Removing contacts in Outlook 2000

Status
Not open for further replies.

marcdoyle

Technical User
Dec 18, 2002
95
GB
I am trying to write some VBA code to automatically delete all the contacts in a certain folder "FB Contacts" and then add new contacts to this folder which I obtain from a list i will get from Active Directory, this is to create a self updating list of employees in our company without the expense of Exchange.

I have got the delete part working, using the following code:

Declarations:
Public objOutlook As Outlook.Application
Public objAddressList As Outlook.AddressList
Public objAddressEntry As Outlook.AddressEntry


Private Sub Application_startup()
Set objAddressList = Outlook.Session.AddressLists("FB Contacts")
On Error GoTo deldone
For Each objAddressEntry In objAddressList.AddressEntries
objAddressEntry.Delete
Next

This code successfully deletes all the contacts, and then causes an error when the list is empty, which pushes it onto the deldone: label which is just before the code to add the new contacts.

To make a new contact I am typing:

deldone:
objAddressList.AddressEntries.Add "SMTP", "test", "test@test.com"

but instead of creating the contact, i get the following error:

"Run Time Error -
Could not complete the operation because the service provider does not support it"

Can anyone know why it won't add the contact?

Thanks in advance

Marc

_____________________________________________________________________________________________________________________
There are 10 kinds of people in the world; those who understand binary and those who don't.
 
update:

I am now using this code to create a contact, but cannot figure out how to choose where to save the contacts. It automatically saves them in the default contacts folder, not the "FB Contacts" one i created.

Set conOutLook = Outlook.Application.CreateItem(olContactItem)
With conOutLook
.FirstName = "Marc"
.LastName = "Doyle"
.Email1Address = "marc.doyle"
.Save
End With
Set conOutLook = Nothing


Any ideas would be appreciated

_____________________________________________________________________________________________________________________
There are 10 kinds of people in the world; those who understand binary and those who don't.
 
update 2:

have figured this out on my own now.

_____________________________________________________________________________________________________________________
There are 10 kinds of people in the world; those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top