Link to home
Start Free TrialLog in
Avatar of erezabou
erezabou

asked on

outlook business contacts manager link

Hi,
I would like to create an opportunity in outlook business contact manager and add a comment in a custom field.
Creation off the opportunity works but can't find how to write in the custom field.
Thanks
Sub CreateOpportunityWithAccount()

   Dim olApp As Outlook.Application
   Dim objNS As Outlook.Namespace

   Dim bcmRootFolder As Outlook.Folder
   Dim olFolders As Outlook.Folders
   Dim bcmAccountsFldr As Outlook.Folder
   Dim bcmOppFolder As Outlook.Folder
   Dim newAcct As Outlook.ContactItem
   Dim newOpportunity As Outlook.TaskItem

   Set olApp = CreateObject("Outlook.Application")
   Set objNS = olApp.GetNamespace("MAPI")
   Set olFolders = objNS.Session.Folders

   Set bcmRootFolder = olFolders("Business Contact Manager")
   Set bcmAccountsFldr = bcmRootFolder.Folders("Accounts")
   Set bcmOppFolder = bcmRootFolder.Folders("Opportunities")

   Set newAcct = bcmAccountsFldr.Items.Add("IPM.Contact.BCM.Account")
   newAcct.FullName = "Wide World Importers"
   newAcct.FileAs = "Wide World Importers"
   newAcct.Email1Address = "someone@example.com"
   newAcct.Save

   Set newOpportunity = bcmOppFolder.Items.Add("IPM.Task.BCM.Opportunity")
        newOpportunity.Subject = "Opportunity For Wide World Importers to enter into Retail Field"
        
        'Add to a custom field: 'Total Income'
        newOpportunity.....
   
   If (newOpportunity.UserProperties("Parent Entity EntryID") Is Nothing) Then
        Set userProp = newOpportunity.UserProperties.Add("Parent Entity EntryID", olText, False, False)
        userProp.Value = newAcct.EntryID
   End If

   newOpportunity.Save

   Set newOpportunity = Nothing
   Set newAcct = Nothing
   Set bcmOppFolder = Nothing
   Set bcmAccountsFldr = Nothing
   Set bcmRootFolder = Nothing
   Set olFolders = Nothing
   Set objNS = Nothing
   Set olApp = Nothing

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DavidT543
DavidT543
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial