Rediger

Del via


DistListItem.AddMember method (Outlook)

Adds a new member to the specified distribution list. The distribution list contains Recipient objects that represent valid email addresses.

Syntax

expression.AddMember (Recipient)

expression A variable that represents a DistListItem object.

Parameters

Name Required/Optional Data type Description
Recipient Required Recipient The recipient to be added to the list.

Remarks

Use the AddMembers method to add multiple members to a given distribution list.

Example

The following Microsoft Visual Basic for Applications (VBA) example creates a new DistributionList object and adds a recipient to it. If the specified recipient is not valid, the AddMember method will fail. To run this example, replace 'Dan Wilson' with a valid recipient name.

Sub AddNewMember() 
 
 'Adds a member to a new distribution list 
 
 
 
 Dim objItem As Outlook.DistListItem 
 
 Dim objMail As Outlook.MailItem 
 
 Dim objRcpnt As Outlook.Recipient 
 
 
 
 Set objMail = Application.CreateItem(olMailItem) 
 
 
 
 Set objItem = Application.CreateItem(olDistributionListItem) 
 
 'Create recipient for distlist 
 
 Set objRcpnt = Application.Session.CreateRecipient("Dan Wilson") 
 
 objRcpnt.Resolve 
 
 objItem.AddMember objRcpnt 
 
 'Add note to list and display 
 
 objItem.DLName = "Northwest Sales Manager" 
 
 objItem.Body = "Regional Sales Manager - NorthWest" 
 
 objItem.Save 
 
 objItem.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.