none
Outlook 2013: Macro to Create Journal from selected contact RRS feed

  • Question

  • Below is a macro to create a Journal from a Selected Contact.

    Issue:  How do I modify the below macro to populate the "Contact Linking" field (with contact) at the bottom of the Journal?

    Note: Contact Linking Field was turned on by the following registry edit.

               Outlook 2013 Registry key:
               In Outlook 2013, the interface option has been removed and support for Contact Linking can

              only be enabled via a Registry key.
              Key: HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Preferences
              Value name: ShowContactFieldObsolete
              Value type: REG_DWORD
              Value: 1

    Macro:

    Sub CreateJournalForcontact()
     
    If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
     Set oContact = ActiveExplorer.Selection.Item(1)
     
    Dim oJournal As JournalItem
    Set oJournal = Application.CreateItem(olJournalItem)
     
     With oJournal
     .Companies = oContact.CompanyName
     .ContactNames = ContactField
     .ContactNames = oContact.FullName
     .Body = oContact.MailingAddress
     .Categories = oContact.Categories
      .Display
      .StartTimer
     
    End With
      Set oJournal = Nothing
     
    Else
    MsgBox "Sorry, you need to select a contact"
    End If
     
    End Sub

    • Moved by Steve Fan Wednesday, August 20, 2014 8:22 AM macro related
    Tuesday, August 19, 2014 2:12 PM

Answers

  • Hello Lightjag,

    The Link contacts in Outlook 2013 forum thread discusses a similar question.

    The What's new for Outlook 2013 developers article contains the following text:

    Support for contact linking

    The contact linking feature and its object model support (through the Link and Links objects) has been deprecated. The Links property for each item object now returns Null (Nothing in Visual Basic), and you should modify any existing code to handle this behavior.

    As you may see the Links property you are interested in was removed and can't be used any longer in Outlook 2013+.

    As a workaround, you can implement that feature on your own in the add-in simply storing EntryID values in a custom property (see UserProperties). And when a linked item is required you can use the GetItemFromID method of the Namespace class to get an instance of the ContactItem class.

    Wednesday, August 20, 2014 9:44 AM
  • If using Redemption is an option, RDOMail.Links still returns a valid object and functions properly as long as Outlook display it.

    If TypeName(Application.ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
      Set oContact = Application.ActiveExplorer.Selection.Item(1)
      'create Journal item using Redemption
      set Session = CreateObject("Redemption.RDOSession")
      Session.MAPIOBJECT = Application.Session.MAPIOBJECT
      set rContact = Session.GetRDOObjectFromOutlookObject(oContact)
      set rJournal = Session.GetDefaultFolder(olFolderJournal).Items.Add
      rJournal.Links.Add(rContact)
      rJournal.Save
      'reopen the item in Outlook
      set oJournal = Application.Session.GetItemfromID(rJournal.EntryId)
      With oJournal
      .Companies = oContact.CompanyName
      .ContactNames = ContactField
      .ContactNames = oContact.FullName
      .Body = oContact.MailingAddress
      .Categories = oContact.Categories
      .Display
      .StartTimer
    'End With
    
    End If


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Wednesday, August 20, 2014 1:56 PM

All replies

  • Hi,

    This forum is for general questions and feedback related to Outlook. Since this issue is more related to coding, I'll move this question to the MSDN forum:

    http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=outlookdev

    The reason why we recommend posting appropriately is you will get the most qualified poolof respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Steve Fan
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs.

    Wednesday, August 20, 2014 8:21 AM
  • Hello Lightjag,

    The Link contacts in Outlook 2013 forum thread discusses a similar question.

    The What's new for Outlook 2013 developers article contains the following text:

    Support for contact linking

    The contact linking feature and its object model support (through the Link and Links objects) has been deprecated. The Links property for each item object now returns Null (Nothing in Visual Basic), and you should modify any existing code to handle this behavior.

    As you may see the Links property you are interested in was removed and can't be used any longer in Outlook 2013+.

    As a workaround, you can implement that feature on your own in the add-in simply storing EntryID values in a custom property (see UserProperties). And when a linked item is required you can use the GetItemFromID method of the Namespace class to get an instance of the ContactItem class.

    Wednesday, August 20, 2014 9:44 AM
  • Not sure I follow.  Is it not possible to edit the above macro to populate the "Contact Link" field? (which I turned on by the registry edit.  If I click on the Contact Link I am able to manually pick the contact name.)

    If you have a solution, please provide in explicit steps #1, #2 etc. (so I can follow your instructions) 

    Thanks for your help.

    Wednesday, August 20, 2014 1:15 PM
  • The Links collection returns null now, as Eugene mentioned. That's what you need to add contact linking using code. Since that's the case you can no longer use linking in your code, and you can expect that it might be completely removed even from the UI in version next.

    In addition I wouldn't bet on Journal items remaining around for all that much longer. No further investment in Journal items is being made by the product group and word is that they're going to be deprecated also in the near future.

    You can use Eugene's idea of a user property to store the id's of the items to link, but those items won't be displayed in the links control on the form and you'd need to create code to call the NameSpace.GeSelectNames() dialog to get the contacts to add to your user property as links. You'd also need to display the custom links field. You'd do that with either a custom form or a form region (which requires a COM addin).


    Ken Slovak MVP - Outlook

    Wednesday, August 20, 2014 1:29 PM
    Moderator
  • No, it is not possible. The required properties were marked as deprecated and not available for Outlook 2013.

    As i already wrote, you can get the EntryID values from contacts you need to link and save them to a user property. Later you can use the GetItemFromID method of the Namespace class to get an instance of the ContactItem class. Just pass the entry id value stored in a user property to the GetItemFromID method to get the linked contact.

    Wednesday, August 20, 2014 1:30 PM
  • If using Redemption is an option, RDOMail.Links still returns a valid object and functions properly as long as Outlook display it.

    If TypeName(Application.ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
      Set oContact = Application.ActiveExplorer.Selection.Item(1)
      'create Journal item using Redemption
      set Session = CreateObject("Redemption.RDOSession")
      Session.MAPIOBJECT = Application.Session.MAPIOBJECT
      set rContact = Session.GetRDOObjectFromOutlookObject(oContact)
      set rJournal = Session.GetDefaultFolder(olFolderJournal).Items.Add
      rJournal.Links.Add(rContact)
      rJournal.Save
      'reopen the item in Outlook
      set oJournal = Application.Session.GetItemfromID(rJournal.EntryId)
      With oJournal
      .Companies = oContact.CompanyName
      .ContactNames = ContactField
      .ContactNames = oContact.FullName
      .Body = oContact.MailingAddress
      .Categories = oContact.Categories
      .Display
      .StartTimer
    'End With
    
    End If


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Wednesday, August 20, 2014 1:56 PM