Adding a distribution list to a distributionlist (distlistitem)

  • Thread starter Thread starter Søren Godthardt Hansen
  • Start date Start date
S

Søren Godthardt Hansen

Hey.

I need to add a distlistitem (a distribution list) as a sublist to another
distribution list, but I can't seem to find a method in the API which is
allowing it.

I have no problems adding recipients to the list, but I have come across a
limit to distribution lists at about 2KB (around 100 members), so therefore
I need build a list from a number of sublist.

Please help !

Søren
 
Same method: Created a resolved Recipient using that DL.

The real question is whether a DL is an appropriate solution at all, given the management headaches.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Hey Sue.

Thank you for the answer - I bought your book "Microsoft Outlook
Programming", and found it extremely interesting - unfortunately it doesn't
answer this question.

When I try to cast a distlistitem to a recipient using the
distlistitem.addMember, I recieve a runtime error (as I would expect) - what
have I missed ??

The solution will not generate management headaches, since it is a read-only
export from a CRM (not MS) -database.

Best regards

Søren

"Sue Mosher [MVP-Outlook]" <[email protected]> skrev i en meddelelse
Same method: Created a resolved Recipient using that DL.

The real question is whether a DL is an appropriate solution at all, given
the management headaches.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Could you show a code snippet, please?

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

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



Søren Godthardt Hansen said:
Hey Sue.

Thank you for the answer - I bought your book "Microsoft Outlook
Programming", and found it extremely interesting - unfortunately it doesn't
answer this question.

When I try to cast a distlistitem to a recipient using the
distlistitem.addMember, I recieve a runtime error (as I would expect) - what
have I missed ??

The solution will not generate management headaches, since it is a read-only
export from a CRM (not MS) -database.

Best regards

Søren

"Sue Mosher [MVP-Outlook]" <[email protected]> skrev i en meddelelse
Same method: Created a resolved Recipient using that DL.

The real question is whether a DL is an appropriate solution at all, given
the management headaches.
 
Hey Sue.

Sub CreateDistList()
'Try to add a distribution list to a distribution list

Dim olApp As Outlook.Application
Dim objItem As DistListItem
Dim objItem2 As DistListItem
Dim objRcpnt As Recipient
Dim TempItem As Outlook.MailItem

Set olApp = Outlook.Application
Set TempItem = olApp.CreateItem(olMailItem)



'Create recipient for list
Set objRcpnt = TempItem.Recipients.Add("(e-mail address removed)")
objRcpnt.Resolve

'Create a distribution list
Set objItem = olApp.CreateItem(olDistributionListItem)
objItem.DLName = "Main DistList"
objItem.Save

'Create another list to be added til the first (main)
Set objItem2 = olApp.CreateItem(olDistributionListItem)
objItem2.DLName = "Sub DistList"
objItem.AddMember objRcpnt
objItem2.Save

'OK - so fare


'This generates a type error (as I would expect)
objItem.AddMember objItem2
objItem.Save

End Sub


"Sue Mosher [MVP-Outlook]" <[email protected]> skrev i en meddelelse
Could you show a code snippet, please?

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

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



Søren Godthardt Hansen said:
Hey Sue.

Thank you for the answer - I bought your book "Microsoft Outlook
Programming", and found it extremely interesting - unfortunately it
doesn't
answer this question.

When I try to cast a distlistitem to a recipient using the
distlistitem.addMember, I recieve a runtime error (as I would expect) -
what
have I missed ??

The solution will not generate management headaches, since it is a
read-only
export from a CRM (not MS) -database.

Best regards

Søren

"Sue Mosher [MVP-Outlook]" <[email protected]> skrev i en meddelelse
Same method: Created a resolved Recipient using that DL.

The real question is whether a DL is an appropriate solution at all, given
the management headaches.
 
objItem2 is a DistListItem, not a Recipient. You can use CreateRecipient to return a Recipient object from objItem2:

Set recip = Application.Session.CreateRecipient(objItem2.Subject)

If the name of the DL is not unique or if the DL is not in a folder used for address solution, it won't resolve into a Recipient.

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

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



Søren Godthardt Hansen said:
Hey Sue.

Sub CreateDistList()
'Try to add a distribution list to a distribution list

Dim olApp As Outlook.Application
Dim objItem As DistListItem
Dim objItem2 As DistListItem
Dim objRcpnt As Recipient
Dim TempItem As Outlook.MailItem

Set olApp = Outlook.Application
Set TempItem = olApp.CreateItem(olMailItem)



'Create recipient for list
Set objRcpnt = TempItem.Recipients.Add("(e-mail address removed)")
objRcpnt.Resolve

'Create a distribution list
Set objItem = olApp.CreateItem(olDistributionListItem)
objItem.DLName = "Main DistList"
objItem.Save

'Create another list to be added til the first (main)
Set objItem2 = olApp.CreateItem(olDistributionListItem)
objItem2.DLName = "Sub DistList"
objItem.AddMember objRcpnt
objItem2.Save

'OK - so fare


'This generates a type error (as I would expect)
objItem.AddMember objItem2
objItem.Save

End Sub
When I try to cast a distlistitem to a recipient using the
distlistitem.addMember, I recieve a runtime error (as I would expect) -
what
have I missed ??

The solution will not generate management headaches, since it is a
read-only
export from a CRM (not MS) -database.

Best regards

Søren

"Sue Mosher [MVP-Outlook]" <[email protected]> skrev i en meddelelse
Same method: Created a resolved Recipient using that DL.

The real question is whether a DL is an appropriate solution at all, given
the management headaches.
 
Dear friends,I have a question.I have added the name of the sub distribution list to the main distribution list in graphical interfaces. But I don't know how to actualize that with VBA programe. Help me,please!
Thank you!
 
Back
Top