다음을 통해 공유


How to access an appointment item linked to BCM Contact's communication history using Outlook Object Model programmatically?

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) usingParent 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
         allContacts1.Sort ("CompanyName")
         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 
                         oAppas.Display
                     End If
                 Next
         Next
 End Sub

Hope this helps!!!

Comments

  • Anonymous
    June 28, 2011
    That is a nice example. I am looking to export the BCM contacts via VBS, please let me know if you have done so, or any reference to the BCM object.