AddMember Method

Microsoft Outlook Visual Basic

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 example creates a new Recipient object and adds the recipient to the distribution list. If the specified recipient is not valid, the AddMember method will fail.

Sub AddNewMember()
'Adds a new member to the distribution list

    Dim olApp As Outlook.Application
    Dim objItem As DistListItem
    Dim objMail As MailItem
    Dim objRcpnt As Recipient

    Set olApp = Outlook.Application
    Set objMail = olApp.CreateItem(olMailItem)
    'Create recipient for list
    Set objRcpnt = objMail.Recipients.Add("Jeff Smith")
    Set objItem = olApp.CreateItem(olDistributionListItem)
    objItem.AddMember Recipient:=objRcpnt
    'Add note to list and display
    objItem.Body = "Regional Sales Manager - NorthWest"
    objItem.Display

End Sub