RemoveMember Method

Microsoft Outlook Visual Basic

RemoveMember Method

       

Removes an individual member from a given distribution list.

expression.RemoveMember(Recipient)

expression   Required. An expression that returns a DistListItem object.

Recipient  Required Recipient. The Recipient to be removed from the distribution list.

Example

The following example removes a member from the distribution list called Group List. The RemoveMember method will fail if the specified recipient is not valid.

Sub RemoveRec()
'Remove a recipient from the list and displays new list.

    Dim olApp As Outlook.Application
    Dim objDstList As DistListItem
    Dim objName As NameSpace
    Dim objRcpnt As Recipient
    Dim objMail As MailItem

    Set olApp = Outlook.Application
    Set objName = olApp.GetNamespace("MAPI")
    Set objDstList = objName.GetDefaultFolder(olFolderContacts).Items("Group List")
    Set objMail = olApp.CreateItem(olMailItem)
    Set objRcpnt = objMail.Recipients.Add(Name:="Jeff Smith")
    objDstList.RemoveMember Recipient:=objRcpnt
    objDstList.Display
    objDstList.Body = "Last Modified: " & Now

End Sub