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

DistListItem Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.