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”
- To start with, launch your Outlook application.
- 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.
- Subsequently, in the “Microsoft Visual Basic for Applications” window, you need to open “ThisOutlookSession” project.
- 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 = "email@example.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 ("firstname.lastname@example.org") objReplyAll.Display Cancel = True End Sub
- After that, you ought to sign this macro.
- Later change your Outlook macro settings to enable the signed macros.
- Eventually restart your Outlook to activate the new VBA project.
- 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.
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