Create an Opportunity linked to a Business Contact
Article
Outlook Developer Reference
Create an Opportunity linked to a Business Contact
You can create an Opportunity object and link it to a new or existing Business Contact object. If linked with a Business Contact, the History section of the Business Contact form displays details of the Opportunity and the Link To field on the Opportunity form displays the Business Contact name.
The following C# and Visual Basic for Applications (VBA) examples show how to create a new Opportunity and link it to a new Business Contact object.
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim olFolders As Outlook.Folders
Dim bcmRootFolder As Outlook.Folder
Dim bcmContactsFldr As Outlook.Folder
Dim bcmOppFolder As Outlook.Folder
Dim newContact 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 bcmContactsFldr = bcmRootFolder.Folders("Business Contacts")
Set bcmOppFolder = bcmRootFolder.Folders("Opportunities")
Set newOpportunity = bcmOppFolder.Items.Add("IPM.Task.BCM.Opportunity")
newOpportunity.Subject = "Opportunity For Wide World Importers to enter into Retail Field"
If (newOpportunity.UserProperties("Parent Entity EntryID") Is Nothing) Then
Set userProp = newOpportunity.UserProperties.Add("Parent Entity EntryID", olText, False, False)
userProp.Value = newContact.EntryID
End If
newOpportunity.Save
Set newOpportunity = Nothing
Set newContact = Nothing
Set bcmOppFolder = Nothing
Set bcmContactsFldr = Nothing
Set bcmRootFolder = Nothing
Set olFolders = Nothing
Set objNS = Nothing
Set olApp = Nothing