Partager via


AddMember Method

Adds a new member to the specified distribution list. The distribution list contains **Recipient**objects that represent valid e-mail addresses.

expression.AddMember(Recipient)

*expression   * Required. An expression that returns a **DistListItem**object.

Recipient   Required. The recipient to be added to the list.

Remarks

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

Example

The following Microsoft Visual Basic/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 olApp As Outlook.Application
    Dim objItem As Outlook.DistListItem
    Dim objMail As Outlook.MailItem
    Dim objRcpnt As Outlook.Recipient

    Set olApp = New Outlook.Application
    Set objMail = olApp.CreateItem(olMailItem)
    
    Set objItem = olApp.CreateItem(olDistributionListItem)
    'Create recipient for distlist
    Set objRcpnt = olApp.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

Applies to | DistListItem Object

See Also | AddMembers Method | DistListItem Object | Recipient Object | Recipients Object