How to Auto Add the Sender of an Email to Your Contacts When Replying It in Outlook

More often than not, you would like to add the sender of an email which you reply to your Outlook contacts. This article will tell you how to automate it with Outlook VBA.

Actually, in the earlier version of MS Outlook, there is a native feature which can auto add the email addresses of outgoing emails to your Outlook address book. But this function is abandoned in the latest versions. Hence, as usual, you have to add the email addresses to your Outlook address book by yourself, which may be a bit troublesome for you.

Moreover, in most situations, you simply want to add the persons whose emails you’ve replied to, instead of the email addresses of all outgoing emails. In response to this issue, here is a quick method, using Outlook VBA, to auto add the sender of an email to your Contacts folder when you reply it.

Auto Add the Sender of an Email to Your Contacts When Replying It

  1. In the first place, launch Outlook application.
  2. Then press “Alt + F11” key buttons to access Outlook VBA editor.
  3. Subsequently, in the popup window, double click on the “ThisOutlookSession” project to open it.
  4. After that, copy and paste the following VBA codes into the project.
Public WithEvents objExplorer As Outlook.Explorer
Public WithEvents objMail As Outlook.MailItem

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

Private Sub objExplorer_SelectionChange()
    On Error Resume Next
    Set objMail = objExplorer.Selection.Item(1)
End Sub

Private Sub objMail_Reply(ByVal Response As Object, Cancel As Boolean)
    Dim strSenderAddress As String
    Dim objContacts As Outlook.Items
    Dim i As Long
    Dim strFilter As String
    Dim objContact As Outlook.ContactItem
    Dim objNewContact As Outlook.ContactItem
 
    strSenderAddress = objMail.SenderEmailAddress
    Set objContacts = Outlook.Application.Session.GetDefaultFolder(olFolderContacts).Items
 
    'Check if the sender has already existed in your Contacts folder
    For i = 1 To 3
        strFilter = "[Email" & i & "Address] = " & strSenderAddress
        Set objContact = objContacts.Find(strFilter)
        If Not (objContact Is Nothing) Then
           Exit For
        End If
    Next
 
    'If not existed, create a new contact for the sender
    If objContact Is Nothing Then
       Set objNewContact = Outlook.Application.CreateItem(olContactItem)
       With objNewContact
            .FullName = objMail.SenderName
            .Email1Address = strSenderAddress
            .Categories = "From Email"
            .Save
            .Display
       End With
    End If
End Sub

VBA Codes - Auto Add the Sender of an Email to Your Contacts When Replying It

  1. Later you need to sign the new added VBA project.
  2. Next you can exit the VBA editor and restart Outlook to activate the macro.
  3. Eventually you can have a try.
  • Firstly, select an email and click the “Reply” button in ribbon.Reply to the Selected Email
  • Then, if the sender hasn’t existed in your default contact folder, Outlook will create a new contact for the sender and display it at once.New Contact from Email

Get Rid of Vexing Outlook Issues

As Outlook is vulnerable, perhaps you have been plagued by Outlook errors for a long time. In reality, as long as you make sufficient and proper precautions, you’ll be able to get rid of them. For instance, when you encounter Outlook damage, if you have prepared a potent Outlook repair tool in vicinity, you can eliminate it in quick time.

Author Introduction:

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

Comments are closed.