Freigeben über


Add an Outlook Toolbar Button to Create a Business Note

It is often necessary to create a Business Note for a contact when you are in a hurry.  To simplify this process, you can create a button on your Outlook toolbar:
1.) Verify that your security settings will prompt you to run unsigned macros by selecting "Tools | Trust Center..." from the main Outlook window. Then click "Macro Security" and select "Warnings for all macros" and click "OK"
2.) Create a Macro from the main Outlook window by selecting "Tools | Macro | Macros..."
3.) Type "Note" as the Macro Name, then click "Create"
4.) The Visual Basic editing window will open.  On the left-hand side is a project navigation pane.  Right-click on the top-level item named "Project1" and select "Project1 Properties..."
5.) Change "Project1" to "Business" and click "OK"
6.) In the main code area, you'll see "Sub Note()", followed by "End Sub". Replace those two lines with the VBA code below, then click Save.
7.) Close the Visual Basic window to return to Outlook
8.) Right-click on the Outlook toolbar and click "Customize..."
9.) Select the "Commands" tab, select the "Macro" from the Categories list, then drag "Business.Note" to the standard Outlook toolbar and click "Close"
on the "Customize" dialog.
10.) Select a business contact or account, then click the "Business.Note" button.

'////////////////////////////////////////////////////////////////////////
' Create a New Business Note for the selected Business Contact
Sub Note()
    ' Get a reference to the MAPI namespace
    Dim objNS As Outlook.NameSpace
    Set objNS = Application.GetNamespace("MAPI")

    ' Get a reference to the currently selected Outlook folder
    Dim currentFolder As Outlook.Folder
    Set currentFolder = Application.ActiveExplorer.currentFolder

    ' Make sure at least one item is selected
    If Application.ActiveExplorer Is Nothing Then
        MsgBox "Please select an item"
        Exit Sub
    End If
    If Application.ActiveExplorer.selection Is Nothing Then
        MsgBox "Please select an item"
        Exit Sub
    End If

    ' The parent item's EntryID, if any
    Dim parentEntryID As String
    parentEntryID = "" ' Initialize to empty string
   
    ' Get a reference to the currently selected item
    Dim oItem As Object
    Set oItem = Application.ActiveExplorer.selection(1)
    If Not (oItem Is Nothing) Then
        ' Verify that this item is located in the Business Contact
        ' Manager Outlook Store
        If 1 = InStr(1, currentFolder.FullFolderPath, _
           "\\Business Contact Manager\", vbTextCompare) Then
            ' Only get the EntryID if this is a Business Contact, Account,
            ' Opportunity, or Business Project
            If oItem.MessageClass = "IPM.Contact.BCM.Contact" Or _
               oItem.MessageClass = "IPM.Contact.BCM.Account" Or _
               oItem.MessageClass = "IPM.Task.BCM.Opportunity" Or _
               oItem.MessageClass = "IPM.Task.BCM.Project" Then
                parentEntryID = oItem.EntryID
            End If
        End If
    End If
   
    ' Get the root BCM folder
    Dim olFolders As Outlook.Folders
    Dim bcmRootFolder As Outlook.Folder
    Set olFolders = objNS.Session.Folders
    Set bcmRootFolder = olFolders("Business Contact Manager")

    ' Locate the Communication History folder
    Dim historyFolder As Outlook.Folder
    Set historyFolder = bcmRootFolder.Folders("Communication History")

    ' Create a new history item
    Const BusinessNoteMessageClass = "IPM.Activity.BCM.BusinessNote"
    Dim newBusinessNote As Outlook.JournalItem
    Set newBusinessNote = historyFolder.Items.Add(BusinessNoteMessageClass)
   
    ' Set the type to Business Note
    newBusinessNote.Type = "Business Note"

    ' If we found a valid parent EntryID
    If parentEntryID <> "" Then
        ' Link the new Business Note to the selected BCM item
        Dim parentEntityEntryID As Outlook.userProperty
        Set parentEntityEntryID = _
            newBusinessNote.UserProperties("Parent Entity EntryID")
        If (parentEntityEntryID Is Nothing) Then
            Set parentEntityEntryID = _
                newBusinessNote.UserProperties.Add("Parent Entity EntryID", _
                olText, False, False)
        End If
        parentEntityEntryID.value = parentEntryID
   
        ' Linking cont'd
        Dim parentEntryIDs As Outlook.userProperty
        Set parentEntryIDs = newBusinessNote.UserProperties("Parent Entry IDs")
        If (parentEntryIDs Is Nothing) Then
            Set parentEntryIDs = _
                newBusinessNote.UserProperties.Add("Parent Entry IDs", _
                olKeywords, False, False)
        End If
        parentEntryIDs.value = parentEntryID
    End If
   
    ' Display the new, empty business note
    newBusinessNote.Display (False)
       
    Set parentEntryIDs = Nothing
    Set parentEntityEntryID = Nothing
    Set newBusinessNote = Nothing
    Set historyFolder = Nothing
    Set bcmRootFolder = Nothing
    Set olFolders = Nothing
    Set oItem = Nothing
    Set currentFolder = Nothing
    Set objNS = Nothing

End Sub
'//////////////////////////////////////////////////////////////////////////

Comments

  • Anonymous
    April 10, 2007
    Excellent addition. Customer loved it but siad that if this could be done to create a phone log also they would be very happy. Any plans for this?
  • Anonymous
    April 10, 2007
    You can easily modify the codefor Phone Log. Change "IPM.Activity.BCM.BusinessNote" to "IPM.Activity.BCM.PhoneLog" and newBusinessNote.Type = "Business Note" to newBusinessNote.Type = "Phone Call"
  • Anonymous
    April 10, 2007
    every time I try to add a 2nd macro it overwrites the first one. Tried this on several computers... same result. can multiple macros be used at the same time?
  • Anonymous
    December 26, 2007
    I didn't even think about macros for BCM. Could you tell me where I can find the API? Thanks!
  • Anonymous
    February 21, 2008
    Hi,I need to add a Business Note (BN)to many Contacts or Oportunities. I thought I could link in maby ways: from the window that opens to selecet contact, account, etc or selecting the recordw you want to link the BN etc. BUT I just realized the LIMIT TO 40 records!I understand the field "Link to" has a limitation but then how to link a BN to much more than 40 records???What I need is to be able to select many (even thousands) of Contacts or Oportunities and then link a BN to all them. The BN maybe very simple even just filling the Subject would be enough.Maybe a macro applied to a search folder? Please give me yourf advice about the best way to bypass the 40 records limitation. Thanks!
  • Anonymous
    February 26, 2008
    Hi rambcm,Currently more than 40 records is not supported.  Multi-selecting records and adding history items is not supported either.  This is a good suggestion and will be considered for future releases.-Sateesh
  • Anonymous
    March 18, 2008
    Is there a macro I can use to export my list of reminders for all of my business contacts?As soon as i leave the office and revert to my offline database, none of my reminders/flags show up.Without setting up a new task for each record, is there anyway of resolving this issue?If not, does anyone know of a macro I can use to export the reminders list on a daily basis so that I have my full to-do list when at home?Thanks
  • Anonymous
    June 18, 2008
    is it possible to add a right click menu so that we click on the email "From" address field and add the contact to BCM contacts (similar to Add to Outlook Contacts)this would save us a lot of time.I think if BCM uses Outlook as email client for business use, why we can't add it to BCM contacts and still thinking Outlook as a personal use?or have BCM its own business email client (similar to Outlook with higher capacity for business use and call it Outlook Business version etc.. and integrate it with BCM better.Thanks,Lewis
  • Anonymous
    October 16, 2011
    The comment has been removed