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.
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.