StartDownloadsServiceSamplesWorkshopsContact DeutschEnglish
 
Samples
General
Outlook®
 
Awarded by
Microsoft since 2005:
mvp logo
VBOffice Info
Visitors1644108
Impressions6223001
Links
Imprint
Privacy Policy
Contact
E-Mail: Remove recipients before sending
Author: Michael BauerHomepage
Date: 20.02.2010Accessed: 14241
  
Description

Does is happen sometimes that you send an email to a recipient you don't want to send to? For instance, sometimes Outlook sends an email to yourself when you hit the 'Reply All' button.

This VBA example checks the list of recipients before sending, and it removes certain addresses from it.

Just copy the line of code starting with 'RemoveThis.Add...' as many times as you need it, and enter the addresses you never want to send an email to.

Private Sub RemoveRecipients(Item As Outlook.MailItem)
  Dim RemoveThis As VBA.Collection
  Dim Recipients As Outlook.Recipients
  Dim R As Outlook.Recipient
  Dim i&, y&
  Set RemoveThis = New VBA.Collection

  ' here add addresses
  RemoveThis.Add "abc@domain.de"
  RemoveThis.Add "test@domain.com"

  Set Recipients = Item.Recipients
  For i = Recipients.Count To 1 Step -1
    Set R = Recipients.Item(i)

    For y = 1 To RemoveThis.Count
      If LCase$(R.Address) = LCase$(RemoveThis(y)) Then
        Recipients.Remove i
        Exit For
      End If
    Next
  Next
End Sub

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  On Error Resume Next
  RemoveRecipients Item
End Sub
 
 

ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more]

 

Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more]

 

SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more]

 

OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more]