How to Auto Insert the Linked Contacts’ Information into the Body of an Outlook Task

If you wish Outlook to automatically insert the linked contacts’ main information in the task body, you can use the method introduced in this article.

Outlook allows you to link contacts to any items, no matter appointments, notes or tasks, etc. For instance, when you create a new task involved with everyone in your team, you can link the corresponding contacts to this task. In this situation, in order to contact them faster, you may be eager to directly insert their main information, such as the email address and telephone number, into the task body. In the followings, we will share a method which can let your Outlook auto do this. If you are interested in it, please read on to get detailed steps.

Auto Insert the Linked Contacts' Information into the Body of an Outlook Task

Auto Insert Linked Contacts’ Main Information in Task Body

  1. For a start, access Outlook VBA editor with reference to the article – “How to Run VBA Code in Your Outlook“.
  2. Next, copy and paste the following VBA code into the “ThisOutlookSession” project.
Public WithEvents objTasks As Outlook.Items

Private Sub Application_Startup()
    Set objTasks = Outlook.Application.Session.GetDefaultFolder(olFolderTasks).Items
End Sub

Private Sub objTasks_ItemAdd(ByVal Item As Object)
    Dim objTask As Outlook.TaskItem
    Dim objLink As Outlook.Link
    Dim i As Long
    Dim objContacts As Outlook.Items
    Dim objLinkedContact As Outlook.ContactItem
    Dim strContactInfo As String
 
    Set objTask = Item
 
    If objTask.Links.Count > 0 Then
 
       Set objContacts = Outlook.Application.Session.GetDefaultFolder(olFolderContacts).Items
 
       For i = 1 To objTask.Links.Count
           Set objLink = objTask.Links(i)
           If objLink.Type = olContact Then
 
              'Find the linked Contacts
              Set objLinkedContact = objContacts.Find("[FullName] = '" & objLink.Name & "'")
  
              'Get the linked Contacts' information
              strContactInfo = strContactInfo & vbCr & objLinkedContact.FullName & ": " & " " & objLinkedContact.Email1Address & " " & objLinkedContact.BusinessTelephoneNumber
 
          End If
       Next
 
       'Insert the contact information into Body
       objTask.Body = objTask.Body & "----------------------------------" & vbCr & strContactInfo
       objTask.Save
    End If
End Sub

VBA Code - Auto Insert Linked Contacts' Information in Task Body

  1. After that, put your cursor in the “Application_Startup” subroutine and press “F5” key button, which will activate your macro.
  2. From now on, every time when a new task is created and saved, Outlook will auto check the linked contacts in the task.  And it will insert their information in the body, like the following screenshot.Auto Inserted Contacts' Information in Task Body

Resolve Outlook Problems as Soon as Possible

Have you ever received any error messages during using your Outlook? For most small problems, a simple restart can solve them with effortless ease. Even though the issues persist, you still can make use of inbox repair tool to fix them. There is no denying that the worst case is that the internal utility also fails. At that point, you have to use a powerful and specialized repair tool, such as DataNumen Outlook Repair. It can repair Outlook like a breeze.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql corruption 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 *