About Address Lists and Contacts Folder

B

Bernie

Everyone has been very nice in this group and provided some great help.
This posting is to summarize a few items of note that were helpful in
our project. This information comes from the actual coding that worked
on our project and from experiments we ran with the code.

The connection between an Address List and a Contact Folder is not
clearly outlined in most documentation we could find.

First, not all Contacts Folders have an Address list associated with
them. The address list for a particular Contact Folder is created when
under that Contact Folder's properties under the "Outlook Address Book"
tab the "Show this folder as e-mail address book" is checked.

Furthermore, the name used there can be changed to be anything. It
does default to be the same as the name of the Contact Folder itself.
But there is no reason to assume this is true. Some commentaries
suggest that the names are the same but they don't have to be.

The connection between the list and the folder can be found in the
"ShowAsOutlookAB" property and the "AddressBookName".

For our programs to properly process contact folder entries and their
associated email addresses we must have...

1) "DefaultItemType" is "olContactItem"
2) "ShowAsOutlookAB" is "true"
3) Able to located "AddressBookName" in the "AddressLists".

There is some conflicting data on finding Address Books.

Folders can be nested (contact folders included). However Address
Books are in a simple linear list. So for point 3, using the
"AddressBookName" value a simple search can locate the Address list for
that contact folder. The AddressList object can then be saved and you
now have access to both the contact folder and the address list the
system has generated from this folder.

It also seems that the value for "AddressBookName" is always set even
if "ShowAsOutlookAB" is not "true". Outlook sets that value to the
string "Contacts". Which in most cases is always there. This can lead
to some confusion, thinking there is an address list entry for an email
address in a contacts folder when in reality there is none. (For
example the algorithms for the "Resolve" and "ResolveAll" methods
report "Resolved" even if there is no existing entry for that email
address...)

Anyhow, hope this helps someone and saves some time. It sure helped us
out once we understood this.

Thanks again for the all the help.

Bernie
 
S

Sue Mosher [MVP-Outlook]

Good writeup! A few more fine points:

-- Names of address lists in the AddressLists collection do not have to be unique. You could have five lists all with the display name of Contacts. Therefore, getting a list by name may not give you the list you want.

-- The value of the AddressBookName property defaults to the name of the folder, which may or may not be "Contacts."

-- A list may be displayed in the address book but not used for address resolution. The Outlook object model does not expose a property to cause a folder to be included in the address resolution list (and I haven't dug into Outlook Spy or the registry to try to find out where that setting is stored).

-- An address can be resolved without appearing in any of the address lists *if* it's an address in valid SMTP (e-mail address removed) format.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Bernie

Sue, thanks for the comments.

You are right about the names of address lists do not have to be
unique. We ran across that earlier and at that time gave unique names
to the address book names. So I guess that one is sort of an opened
item if our program is to be more general. Seems there should be an
identifier in the contacts folder to insure you get the right address
book.

Also you are correct on the default name (we were wrong on the default
being "Contacts"). Even if the "ShowAsOutlookAB" is "false" then the
"AddressBookName" property is still filled in and will be the name of
the contact folder. So you have to check the "ShowAsOutlookAB" to know
that the "AddressBookName" is correct.

We have some notes on the address resolution topic we were going to put
out as a topic for later reference.

And your comment about address resolution taking place from the RFC
2822 format is a real gotcha on address resolutions. When the
resolution methods are used. It seems the very first thing it does is
attempt to parse the string as an RFC 2822 format. If that succeeds
then there is no other lookup performed and an address entry is created
for that new item. The resolution process is also sort of liberal on
the parsing and allows the use of "()" as well as "<>" to delimit the
address part.

So "My Name<[email protected]>" and "My Name([email protected])" generate the same
address entry with a display name of "My Name" and andaddress of
"(e-mail address removed)".

It may be this behavior is causing some of the different discussions on
how "contacts" verses "email" addresses are inserted into things like
distribution lists. If an email address can be generated from the name
added, it will be created distinct from any other name that may already
be in the address list.

So if you have a contact that is an address book and let's say it has
an entry with the "fullname" of "Alex Contact" and an email address of
"(e-mail address removed)". Then creating a distribution list and adding "Alex
Contact<[email protected]>", the resolution process will create another
address entry with a display name of "Alex Contact" and an email
address of "(e-mail address removed)" which is not a reference to the contact but a
reference to a 'standalone' address entry. You can have even more fun
with this by making the display name in the contact be "Alex Contact".
If you then review the address list you will see two identical entries
one is used for the distribution list and the other for the contact.

Anyhow, thanks again, and hope this collection will help someone else.
(Or maybe ourselves when we do more work with Visual Basic for
Applications and Outlook and have forgotten why all this weird code is
in the application!)

Bernie
 

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