DistListItem.AddMembers Method (Outlook)

Adds new members to a distribution list.

Syntax

expression .AddMembers(Recipients)

expression A variable that represents a DistListItem object.

Parameters

Name

Required/Optional

Data Type

Description

Recipients

Required

Recipients

The members to be added to the distribution list.

Example

This Microsoft Visual Basic for Applications (VBA) example creates a new distribution list and adds the current user and 'Dan Wilson' to the list. If the specified recipient is not valid, the AddMember method will fail. Therefore, to run this example, replace 'Dan Wilson' with a valid recipient name.

Sub AddNewMembers() 
 
 Dim myNameSpace As Outlook.NameSpace 
 
 Dim myDistList As Outlook.DistListItem 
 
 Dim myTempItem As Outlook.MailItem 
 
 Dim myRecipients As Outlook.Recipients 
 
 
 
 Set myNameSpace = Application.GetNamespace("MAPI 
 
 Set myDistList = Application.CreateItem(olDistributionListItem 
 
 Set myTempItem = Application.CreateItem(olMailItem 
 
 Set myRecipients = myTempItem.Recipients 
 
 myDistList.DLName = _ 
 
 InputBox("Enter the name of the new distribution list 
 
 myRecipients.Add myNameSpace.CurrentUser.Name 
 
 myRecipients.Add "Dan Wilson 
 
 myRecipients.ResolveAll 
 
 myDistList.AddMembers myRecipients 
 
 myDistList.Save 
 
 myDistList.Display 
 
End Sub

See Also

Concepts

DistListItem Object Members

DistListItem Object