Mitdasein in the experience of encountering the customer in our common having been cast into the opening of beyng

Thursday, March 06, 2008

Setting a user property on a new Account in VBS

Here's a short script that creates an Account and sets the Active property to true. Have Outlook/BCM running in the profile you want to use.


Dim olYesNo
olYesNo = 6

Dim objOL
Dim objNS
Dim objFolder

Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")
set objBCMFolder = objNS.Folders("Business Contact Manager")
set objBCMObjectsFolder = objBCMFolder.Folders("Business Objects")
set objBCMAccountsFolder = objBCMObjectsFolder.Folders("Accounts")

' create new account
set newAccount = objBCMAccountsFolder.Items.Add("IPM.Contact.BCM.Account")

' give it a name
newAccount.FullName = "accountname"

' create an Active property,
' because it doesn't exist yet
set uProperties = newAccount.UserProperties
set newProp = uProperties.Add("Active", olYesNo)

' we could use newProp but let's confirm that UserProperties
' can be accessed through the ItemProperties array
set iProperties = newAccount.ItemProperties
iProperties("Active").Value = 1

newAccount.Save()

0 Comments:

Post a Comment

<< Home