How to remove an addresslist in outlook ?

A

Anthony_fr

Hi all, and sorry for my english

I'm looking how to remove a addresslist in outlook using VB

I want to remove all entry or one entry without using the folder object and
set the ShowAsOutlookAB=False because some time when the folder contact is
corrupt the entry stay in the adresslists

Thanks All for your help


Here my code

Sub Main()
' Create an Outlook application.
Dim oApp As Outlook.Application
Set oApp = New Outlook.Application

' Get the MAPI namespace.
Dim oNS As Outlook.NameSpace
Set oNS = oApp.Session

' Get the AddressLists collection.
Dim oALs As Outlook.AddressLists
Set oALs = oNS.AddressLists
MsgBox (oALs.Count)

' Loop through the AddressLists collection.
Dim i As Integer
Dim oAL As Outlook.AddressList
For i = 1 To oALs.Count
Set oAL = oALs.Item(i)
'
'! Here : how to do oAl.remove ?
'
Next i
End Sub
 
K

Ken Slovak - [MVP - Outlook]

There are no Remove() or Delete() methods either in the AddressLists or
AddressList collection or object. You can get the AddressEntry of the
corrupted object from the AddressList.AddressEntries collection and delete
that if you want.

The only way to set or change ShowAsOutlookAB is to get the folder you want
and clear that Boolean flag property, so at some point to do that you will
need to access the folder.
 
A

Anthony_fr

OK thanks for your reply.

but I need a way to do this...

So do you know if I can delete the adress book from my profil and recreate
it whit vb ?
It would reset my adresslist as I want.


Others Ideas are welcome
 
K

Ken Slovak - [MVP - Outlook]

No, there's nothing like that which can be done using code. Just delete the
corrupted contact.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top