How to Quickly Add the Email Signature to the Sender’s Contact Details with Outlook VBA

When you receive an email which contains a detailed signature, you may want to add it to the corresponding sender’s contact. Copying and pasting manually is time-consuming. So in this article, we will help you accomplish it with Outlook VBA.

Without any doubts, you must have ever received such emails which include the senders’ detailed information in signature. At that time, you may hope to add the details to the corresponding contact. In general, without extra helps, you will need to look up all your contacts to find the correct one and then copy the signature to its body. It will be quite troublesome. Fortunately, you can realize it via Outlook VBA, which is much faster. Here are the elaborate operations and related VBA codes.

Add the Email Signature to the Sender’s Contact Details

  1. In the first place, you should start Outlook.
  2. Then switch to the “Developer” tab and click on “Visual Basic” button.
  3. In the new popup window, then you need to open a new module. Then select “Insert” > “Module”.Insert a New Module
  4. Subsequently, you ought to copy and paste the following codes into the new module.
Sub AddSignaturetoContact()
    Dim olItem As Outlook.MailItem
    Dim olInspector As Outlook.Inspector
    Dim objDoc As Word.Document
    Dim objWord As Word.Application
    Dim objSel As Word.Selection
    Dim Signature As String
    Dim olContacts As Outlook.Items
    Dim objVariant As Variant
    Dim i As Long
    Dim strBody As String
 
    Set olItem = Outlook.Application.ActiveInspector.CurrentItem
 
    If olItem.Class = olMail Then
       'Select the signature
       Set olInspector = olItem.GetInspector
       If olInspector.EditorType = olEditorWord Then
          Set objDoc = olInspector.WordEditor
          Set objWord = objDoc.Application
          Set objSel = objWord.Selection
          Signature = objSel.Text

          Set olContacts = Outlook.Application.Session.GetDefaultFolder(olFolderContacts).Items
 
         'Go through all the existing contacts to find the corresponding contact
         'And then add the signature to it
         For i = 1 To olContacts.Count
             If olContacts.Item(i).Class = olContact Then
                Set objVariant = olContacts.Item(i)
                If objVariant.Email1Address = olItem.SenderEmailAddress Then
                   strBody = objVariant.Body
                   With objVariant
                        .Body = strBody & vbCrLf & "-----From Signature-----" & vbCrLf & vbCrLf & Signature
                        .Save
                        .Display
                   End With
                End If
             End If
          Next
       End If
    End If
End Sub

VBA Codes - Add the Email Signature to the Sender's Contact Details

  1. After that, you can exit the current window and then open an email.
  2. Then click the down arrow in Quick Access Toolbar of the current message window and select “More Commands”.Select More Commands
  3. Next in the subsequent window, then you should add the new macro to Quick Access Toolbar.Add the New Macro to the QAT in Message Window
  4. After finishing all the steps above, you can have a try finally.
  • Firstly, open the email whose signature you intend to add to contact.
  • Then select all the texts in signature and click the macro button in Quick Access Toolbar, like the following image:Run the Macro
  • Immediately, Outlook will start to look up all the contacts in your default Contact folder. After finding it, Outlook will add the signature to its body and display it, look the following screenshot:Add the Email Signature to the Sender's Contact Details

Handle Tiresome Outlook Issues

As you know, Outlook is error prone although it boasts of multiple features. Thus, for the sake of keeping your Outlook data in good health, you had better not rely on inbox repair tool simply. You have to get hold of a more preeminent corrupted PST repair tool, such as DataNumen Outlook Repair, which can solve the extreme issues that have exceeded the capacity of Scanpst.exe

Author Introduction:

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

Comments are closed.