How to Auto Replace a Specific Recipient with Another When Using “Reply All” in Outlook

For some reasons, you may always need to replace a specific recipient with another when using “Reply All”. In this case, you must hope that Outlook can auto do this task. Thus, in this article, we will teach you how to use VBA to realize it.

In order to protect someone’s privacy or for some other reasons, you may need to change a specific recipient to another when using “Reply All”. With no doubt, if you’re frequently required to do it, you may long for a more effective way which can make Outlook auto accomplish it. However, Outlook doesn’t have such a default function. Thus, you have to seek other means, such as third party utility or VBA. Now, we’ll expose the VBA code to you. Read on to get it in detail.

Auto Replace a Specific Recipient with Another When Using "Reply All"

Auto Replace a Specific Recipient with Another When Using “Reply All”

  1. To start with, launch your Outlook application.
  2. Then in main Outlook window, click the “Visual Basic” button on “Developer” tab or just press “Alt + F11” key buttons to access Outlook VBA editor.
  3. Subsequently, in the “Microsoft Visual Basic for Applications” window, you need to open “ThisOutlookSession” project.
  4. Next copy the following VBA code into this project window.
Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objExplorer As Outlook.Explorer
Public WithEvents objMail As Outlook.MailItem

Private Sub Application_Startup()
    Set objInspectors = Outlook.Application.Inspectors
    Set objExplorer = Outlook.Application.ActiveExplorer
End Sub

Private Sub objExplorer_SelectionChange()
    On Error Resume Next
    If TypeOf objExplorer.Selection.Item(1) Is MailItem Then
       Set objMail = objExplorer.Selection.Item(1)
    End If
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If TypeOf Inspector.CurrentItem Is MailItem Then
       Set objMail = Inspector.CurrentItem
    End If
End Sub

Private Sub objMail_ReplyAll(ByVal Response As Object, Cancel As Boolean)
    Dim objReplyAll As Outlook.MailItem
    Dim objRecipients As Outlook.Recipients
    Dim objRecipient As Outlook.recipient
    Dim strRecipientAddress As String
 
    Set objReplyAll = objMail.ReplyAll
    Set objRecipients = objReplyAll.Recipients
 
    For Each objRecipient In objRecipients
        strRecipientAddress = objRecipient.Address
        'Find & Delete the specific recipient
        'Change the source recipient address as per your own case
        If strRecipientAddress = "source@datanumen.com" Then
           objRecipient.Delete
           Exit For
        End If
    Next
 
    'Add the target email address
    'Change the target email address as per your case
    objRecipients.Add ("target@datanumen.com")
    objReplyAll.Display
 
    Cancel = True
End Sub

VBA Code - Auto Replace a Specific Recipient with Another When Using "Reply All"

  1. After that, you ought to sign this macro.
  2. Later change your Outlook macro settings to enable the signed macros.
  3. Eventually restart your Outlook to activate the new VBA project.
  4. From now on, every time when you select an email and hit “Reply All”. The new replying mail will display with the specific source recipient replaced by a new one.

Avert Troublesome PST Problems

Due to the fact that Outlook can crash now and then with time going, so you have to make sufficient precautions, like persisting in regular PST data backups and keeping a potent Outlook fix tool nearby such as DataNumen Outlook Repair, etc. With the above two, you will be able to escape from PST data loss effectively.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fix sql and outlook repair software products. For more information visit www.datanumen.com

Leave a Reply

Your email address will not be published. Required fields are marked *