Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error Accessing Members of Distribution List

204 views
Skip to first unread message

Doug Haigh

unread,
Jan 11, 2000, 3:00:00 AM1/11/00
to
I have written both VC++ and VB code to access the Members of a distribution
list AddressEntry in my Contacts folder of Outlook 98. Everytime I try to
access the Members field to assign it to a AdressEntries variable or do
something as simple as display the count of Members, I get a COM error. I
sent this same code to another developer and it works fine under Outlook 98
and Outlook 2000.

Any idea of what may be going on?

Doug Haigh

---------------- Code Follows ------------------------
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim newMail As MailItem
Set ns = ol.GetNamespace("MAPI")
ns.Logon , , False, True

Dim aPAB() As Variant
Dim adl As Outlook.AddressList
Dim dl As Outlook.AddressEntry
Dim ae As Outlook.AddressEntry
Dim dle As Outlook.AddressEntries
Dim i As Integer
ReDim aPAB(100, 2)
Set ns = ol.GetNamespace("MAPI") 'Return the personal address book.

For Each adl In ns.AddressLists
Debug.Print "Address list name is " & adl.Name
If adl.Name = "Contacts" Then
Debug.Print "There are " & adl.AddressEntries.Count & " entries in
this list."
For Each dl In adl.AddressEntries
Debug.Print "Entry #" & i & " is " & dl.Name & " of type " &
dl.Type & " display type " & dl.DisplayType

i = i + 1
If dl.Type = "MAPIPDL" Then
'
' NOTE: The following line works just fine and I see the
entries
'
dl.Details
'
' NOTE: The following line produces a COM error
'
Debug.Print "There are " & dl.Members.Count & " entries in
the list"
End If
Next
End If
Next


Ken Slovak - [MVP - Outlook]

unread,
Jan 11, 2000, 3:00:00 AM1/11/00
to
I checked your code in both Outlook 2000 VBA and in VB6. No errors at
all. It was checked in a corporate/workgroup mode installation. Is
that the mode you are in? Check in Help|About. There are many
differences in C/W mode and IMO mode and this might be one of them.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Doug Haigh <Doug_Haigh@REMOVE_THIS.MedAcoustics.com> wrote in message
news:OqjeuFHX$GA.262@cppssbbsa05...

William Pearce

unread,
Jan 13, 2000, 3:00:00 AM1/13/00
to
Like Doug, I too am attempting to access members of a distribution list.

Also, like Doug, I get errors. As well as getting errors at the point Doug
describes, I also get them at other lines. These other errors seem to occur
with simple entries that happen to have no email address, etc. You have to
handle errors by ascertaining their cause.

However the errors are not in Doug's code given. Nothing wrong with that.
Put an error trap in the code and see what errors are returned from Outlook.

At the start of the code put a line like:
On Error GoTo ErrTrap

Then at the bottom, after the final Next and before the End Sub I assume to
be there put:
Exit Sub
ErrHandler:
Debug.Print "Error Desc: " & Err.Description & " : Error Num: " &
Err.Number
Resume Next

Presumably Doug's developer friend and also Ken used neither Doug's address
book or tried to duplicate his conditions at all. The problem must lie in
either of those. In my case Outlook often returns an error descried as "The
messaging interface has returned an unknown error. If the problem persists,
restart Outlook.". Restarting Outlook doesn't help. Although I have
seemingly valid address entries in seemingly valid distribution list
entries, trying to access Outlook.AddressEntry.Members returns the error
previuosly stated.

Ken, could you explain further what you mean about "mode"? I do not
understand.

Assuming that we can get over this problem, I wonder how we traverse the
entries in code? The Outlook Object Model doesn't seem to go into enough
detail, or perhaps I don't understand properly how this stuff works. I don't
just want to put up the dialog as in Doug's line "dl.Details", I want to
access, in code, each address in each dist. list.

Bill Pearce


Ken Slovak - [MVP - Outlook] <kens...@worldnet.att.net> wrote in message
news:uvj6NWIX$GA....@cppssbbsa02.microsoft.com...

Ken Slovak - [MVP - Outlook]

unread,
Jan 13, 2000, 3:00:00 AM1/13/00
to
Outlook 98 and Outlook 2000 have two main operating modes, Internet
only (IMO) and Corporate/Workgroup (C/W) mode. IMO has better and
faster POP3/SMTP support and uses a "reduced functionality" MAPI. C/W
is similar to Outlook 97, and uses the full MAPI. For more information
about the modes: http://www.slipstick.com/outlook/choosingmode.htm

That "no transport" error with a DL most often means that someone in
the list either has a bad email address or unresolved one or none.

As far as testing goes, I tested with what I have, and the tests
indicated that the code itself has no problems inherently. Obviously,
more troubleshooting is required.

A DL can be traversed by getting the DistributionListItem it
represents, using the MemberCount property to get a count of items in
the DL and then using the GetMember method to get each member as a
Recipient item. That Recipient item's Address property is what you
want.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


William Pearce <billp...@beeb.net> wrote in message
news:85k8u4$244g$1...@news.beeb.net...

Doug Haigh

unread,
Jan 13, 2000, 3:00:00 AM1/13/00
to
I am using IMO. Does that mean I cannot access distribution lists?

The distribution list is valid. It only has two entries and both are me.

Is the DistributionListItem in Outlook 2000? I do not see it in Outlook 98
type lib.

Doug Haigh

Doug Haigh

unread,
Jan 13, 2000, 3:00:00 AM1/13/00
to
I converted my Outlook 98 to C/W mode. The address book changed to the
Microsoft Exchange Address Book and I no longer was able to see my group. My
program then ran, but since it did not see any groups there was no problems.
The MS Exch Addr Book would not let me add any entries so I could not add a
new group.

I reverted back to IMO and my group reappeared, but so did the problem.

Doug Haigh

William Pearce

unread,
Jan 14, 2000, 3:00:00 AM1/14/00
to
Ken and Doug

I have looked into operating modes. I was in IMO mode. I changed to CW mode
and all my errors disappeared! It seem that Ken's word about "reduced
functionality" MAPI seemed to pinpoint my problem.

I can now find distribution lists and traverse their members just fine. BTW,
I am using Outlook 2000 and VB5.

So what's happening with Doug when he changes to CW mode? What exactly are
the errors Doug?

Thanks Ken for the help.

Bill Pearce

Ken Slovak - [MVP - Outlook] <kens...@worldnet.att.net> wrote in message

news:#723ugdX$GA.258@cppssbbsa04...

Doug Haigh

unread,
Jan 14, 2000, 3:00:00 AM1/14/00
to
Using VB with Outlook IMO, I get a message box that says 'Run Time error
<88341103>. The operation failed due to a registry or installation problem.
Restart Outlook and try again. If the problem persists, reinstall.'

Using VB with Outlook C/W, I do not get an error because my groups are
missing in the MS Exchange address book. When I try to add a new address
into 'Contacts', the dialog tells me I cannot add into this address book.
So, since I have no groups, I see no errors.

So in IMO I can have DLs in my Contacts folder but cannot access them, in
C/W I cannot have them but can access them.

Doug Haigh

Ken Slovak - [MVP - Outlook]

unread,
Jan 14, 2000, 3:00:00 AM1/14/00
to
However, in IMO mode in Outlook 2000 you can use the DistributionList
items with no problems. I've done so many times. What I wrote about
that item type will work in Outlook 2000 IMO mode.

I haven't really tested the use of the Members of an AddressEntry that
is a DL in Outlook 2000 IMO since a DistributionList item offers more
functionality for the purposes I use them for. I will check out that
type of coding in my Outlook 2000 IMO setup later, when I get a
chance.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams

William Pearce <billp...@beeb.net> wrote in message

news:85mj0j$28rb$1...@news.beeb.net...

Ken Slovak - [MVP - Outlook]

unread,
Jan 14, 2000, 3:00:00 AM1/14/00
to
In Outlook 98 distribution lists (groups) can only be in Contacts
folders in IMO, only in the Personal Address Book in C/W mode. Outlook
2000 C/W does allow distribution lists in the Contacts folder.

Unfortunately I'm not running Outlook 98 on any of my machines any
more, so I can't test your code under Outlook 98.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams

Doug Haigh <Doug_Haigh@REMOVE_THIS.MedAcoustics.com> wrote in message

news:e4lxjsgX$GA.263@cppssbbsa04...

Ken Slovak - [MVP - Outlook]

unread,
Jan 14, 2000, 3:00:00 AM1/14/00
to
In IMO mode all DL's are kept in the Contacts folder, there is no
Personal Address Book.

Yes, DistributionListItem is in the Outlook 2000 object model.

If you use that DL from the user interface you get no errors? The
entries in it (you) are resolved properly?

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Doug Haigh <Doug_Haigh@REMOVE_THIS.MedAcoustics.com> wrote in message

news:OkAANCfX$GA....@cppssbbsa02.microsoft.com...

Ken Slovak - [MVP - Outlook]

unread,
Jan 14, 2000, 3:00:00 AM1/14/00
to
You get that error that you can't add an item to the Contacts folder
in C/W mode even if the item is just a person, and not a DL or group?
It almost sounds as if there is a problem with the installation or the
.pst file you are using.

Have you run Scanpst.exe against that .pst file to make sure there is
no corruption in it? Is Outlook the default MAPI provider, not
something like OE, Eudora or Netscape?

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Doug Haigh <Doug_Haigh@REMOVE_THIS.MedAcoustics.com> wrote in message

news:#Be4#XpX$GA.277@cppssbbsa05...

Doug Haigh

unread,
Jan 14, 2000, 3:00:00 AM1/14/00
to
Yes, the DL is resolved properly.

Doug Haigh

unread,
Jan 14, 2000, 3:00:00 AM1/14/00
to
With Outlook installed in C/W mode...

1) If I select Outlook->File->New->Contact I can add a contact. It shows up
in my contact list.

2) If I select Outlook->Tools->Address Book I bring up the MS Exchange
Address book showing the names from the Contacts folder. When I select New
Entry, it tells me that I cannot create entries for this address book. If I
switch to Display Names from Contacts to Outlook Address Book it tells me
the same thing. The names in the address book for 'Contacts' does not update
when I add a contact through #1 if the contact has no e-mail address.

3) If I go to Start->Programs->Accessories->Address Book and bring up the
Windows Address Book, it brings up a different address book based on my user
id profile (I am in WinNT).

4) If I go into Outlook Express, it has yet another Contacts list that is
different from everything else, but if I press the 'Addresses' button, I get
the Accessories Address book from #3. If I add an address there, it does not
show up in the Contacts unless I import them in.

Lots of address lists. Lots of Contacts lists. When I run my VB program, I
get the entries in the address list specified by #1 & #2. I see no way to
add a distribution list to Outlook this way.

Doug Haigh

Ken Slovak - [MVP - Outlook]

unread,
Jan 17, 2000, 3:00:00 AM1/17/00
to
Take a look at these MS KB articles, they explain some of your
questions:
http://support.microsoft.com/support/kb/articles/q180/8/30.asp
http://support.microsoft.com/support/kb/articles/q182/9/57.asp

You can also get these articles by sending an E-mail with a subject of
"Q180830 Q182957" (without the quotes) to msh...@microsoft.com.

In C/W mode you can't share the address books with OE. You can in
Internet only mode.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Doug Haigh <Doug_Haigh@REMOVE_THIS.MedAcoustics.com> wrote in message

news:#3Czp2tX$GA.255@cppssbbsa04...

Doug Haigh

unread,
Jan 19, 2000, 3:00:00 AM1/19/00
to
I changed my Outlook to C/W code. I added the Personal Address Book service
so that I could create distribution lists. I selected people in my contacts
folder to be part of my distribution. I re-ran my VB code after changing the
folder to use from 'Contacts' to 'Personal Address Book'.

This time it did not list any of my contacts, but did find the distribution
list entry. I issued a 'Details' on it and saw the dialog box, but when I
went to get the Count member, it gave the same error message as before.

Current Score:
1) Outlook IMO mode, using Contacts folder, dist list in Contacts folder,
entries in Contacts folder ->Error
2) Outlook C/W mode, using Personal Address Book, dist list in PAB, entries
in Contacts folder -> Error.

I am 0 for 2 - any other ideas?

Doug Haigh

Sue Mosher [MVP]

unread,
Jan 21, 2000, 3:00:00 AM1/21/00
to
What version of Outlook? I think you're only going to be able to work with
DLs in Outlook 2000 Contacts folders.
--
Sue Mosher
Author of
"Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours"
"Microsoft Outlook 2000 E-mail and Fax Guide"

Outlook and Exchange solutions at http://www.slipstick.com


Doug Haigh <Doug_Haigh@REMOVE_THIS.MedAcoustics.com> wrote in message

news:OtOn0isY$GA.277@cppssbbsa05...

Doug Haigh

unread,
Jan 24, 2000, 3:00:00 AM1/24/00
to

Sue Mosher [MVP] <sue...@slipstick.com> wrote in message
news:eUiZ3O9Y$GA.124@cppssbbsa03...

> What version of Outlook? I think you're only going to be able to work with
> DLs in Outlook 2000 Contacts folders.

I am using Outlook 98. I am trying to access the distribution list as an
AddressEntries object (which I presume it is supposed to be). I have shipped
the code to a friend who set up his computer from the start as C/W mode and
the code works fine in either Outlook 98 and Outlook 2000 using either
msout85.tlb or msout9.tlb.

Doug Haigh

Sue Mosher [MVP]

unread,
Jan 25, 2000, 3:00:00 AM1/25/00
to
I ran across a KB article that might be relevant:
http://support.microsoft.com/support/kb/articles/q178/7/87.asp

--
Sue Mosher
Author of
"Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours"
"Microsoft Outlook 2000 E-mail and Fax Guide"

Outlook and Exchange solutions at http://www.slipstick.com


Doug Haigh <Doug_Haigh@REMOVE_THIS.MedAcoustics.com> wrote in message

news:erMBGSpZ$GA.378@cppssbbsa05...

Doug Haigh

unread,
Feb 2, 2000, 3:00:00 AM2/2/00
to
I am not using CDO; I am using the Outlook tlb. I have installed Outlook 98
in C/w and IMO mode with no luck. I am going to try to install Outlook 2000.
0 new messages