One of my customer is developing application based on Business Contact Manager(BCM) and would like to access an Appointment item linked to BCM contact’s communication history folder using Outlook Object Model(OOM)?
We can refer to the linked item from the Communication History folder(hidden) of BCM as the linked item are saved as Journal Item in it. See how we can added a file as linked item to the BCM contact or other item @ Files.
Here is the VBA sample code snippet to get the reference to an an Appointment item linked to BCM contact’s communication history folder using Outlook Object Model(OOM) using Parent Entity EntryID Property
NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. This sample code is provided for the purpose of illustration only and is not intended to be used in a production environment.
Public Sub OutlookExtractMeetingItem()
Dim ol As Outlook.Application
Dim olns As Outlook.NameSpace
Dim bcmRootFolder As Outlook.Folder
Dim olFolders As Outlook.Folders
Dim bcmContactsFldr As Outlook.Folder
Dim allContacts As Outlook.MAPIFolder 'Used for Personal default folder
Dim allContacts1 As Outlook.Items 'Used for Business Contact folder
Dim contact As Outlook.ContactItem
Dim contacts As Outlook.Items
Dim meetingItem As Outlook.meetingItem
Dim strParentID As String
Dim bcmHistoryFolder As Outlook.Folder
Dim oAppas As Outlook.JournalItem
Dim oItems As Outlook.Items
Dim oItem As Object
Set ol = Application
Set olns = ol.GetNamespace("MAPI")
Set olFolders = olns.Session.Folders
Set bcmRootFolder = olFolders("Business Contact Manager")
'set to the default Contacts in the BCM folder
Set bcmContactsFldr = bcmRootFolder.Folders("Business Contacts")
' Set objAllContacts equal to the collection of all contacts.
Set allContacts1 = bcmContactsFldr.Items
Set bcmHistoryFolder = bcmRootFolder.Folders("Communication History")
Set oItems = bcmHistoryFolder.Items
'Loop through all contact and match "Parent Entity EntryID" to Communication History folder items
For Each contact In allContacts1
strParentID = contact.EntryID
For Each oItem In oItems
Set oAppas = oItem
If strParentID = oAppas.ItemProperties("Parent Entity EntryID") Then
'MsgBox (oAppas.ItemProperties("Parent Entity EntryID").Value)
'We get reference to the appointment object we can work with appointment object once matched
Hope this helps!!!
One of most common question asked by the users of the Outlook Custom form is How to simplify the process to open Custom Forms in Outlook?
Below mentioned articles describes various methods that you can use to make a custom Outlook form more accessible to users:
How to simplify the process to open Organizational Forms in Outlook
How to Open a Form from a Toolbar Button
However, there is a know issue when distributing the VBA macro code to other users as per article mentioned below; so creating a small COM/VSTO add-in is way to go.
Code Does Not Work After You Distribute a VBA Project
In order to know how to develop an COM/VSTO Outlook add-in refer to KB322145 Section: Creating a Component Object Model Add-in Solution.
Hope this helps!!! Have great 2010!!!