Region UserProperties

G

Guest

I have created a new Region (seperate type). I now want ot communicate with
that form from an outside windows application. when i run the code shown
below, i get an error because it can't find the user properties that the code
is requesting. However if i open up the Account form then the actual new
region form, then suddenly all the user properties are available.

Is their a way to communicate with the regions (seperate type) User
properties (UDFs) with out having to open the matching form in out look
itself?

Dim app As New Outlk.Application
Dim olns As Outlk.NameSpace = app.GetNamespace("MAPI")
Dim olFolders As Outlk.Folders = olns.Session.Folders
Dim RootFolder As Outlk.Folder = olFolders("Business Contact Manager")
Dim AccountsFldr As Outlk.Folder = RootFolder.Folders("Accounts")
Dim newAccount As Outlk.ContactItem = Nothing
Dim userProp As Outlk.UserProperty = Nothing


newAccount = AccountsFldr.Items.Find("[Subject]='Account2 Name'")

'the error occures on this line because it cannot find the UDF Called
Carrier
userProp = newAccount.UserProperties.Find("Carrier")
 
S

Sue Mosher [MVP-Outlook]

The symptoms suggest that the property doesn't exist on the item yet. You'll need to add it using the UserProperties.Add method if it doesn't already exist on the individual item.

This isn't a problem when the user opens the item, because opening it invokes the form region, which causes the necessary properties to be created.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

so should i replace the line
userProp = newAccount.UserProperties.Find("Carrier")
with
userProp = itemContact.UserProperties.Add("Carrier", olText)

for each of the properties in the Form Region?

Sue Mosher said:
The symptoms suggest that the property doesn't exist on the item yet. You'll need to add it using the UserProperties.Add method if it doesn't already exist on the individual item.

This isn't a problem when the user opens the item, because opening it invokes the form region, which causes the necessary properties to be created.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Vbasiccode said:
I have created a new Region (seperate type). I now want ot communicate with
that form from an outside windows application. when i run the code shown
below, i get an error because it can't find the user properties that the code
is requesting. However if i open up the Account form then the actual new
region form, then suddenly all the user properties are available.

Is their a way to communicate with the regions (seperate type) User
properties (UDFs) with out having to open the matching form in out look
itself?

Dim app As New Outlk.Application
Dim olns As Outlk.NameSpace = app.GetNamespace("MAPI")
Dim olFolders As Outlk.Folders = olns.Session.Folders
Dim RootFolder As Outlk.Folder = olFolders("Business Contact Manager")
Dim AccountsFldr As Outlk.Folder = RootFolder.Folders("Accounts")
Dim newAccount As Outlk.ContactItem = Nothing
Dim userProp As Outlk.UserProperty = Nothing


newAccount = AccountsFldr.Items.Find("[Subject]='Account2 Name'")

'the error occures on this line because it cannot find the UDF Called
Carrier
userProp = newAccount.UserProperties.Find("Carrier")
 
S

Sue Mosher [MVP-Outlook]

Not quite. You should keep the statement you already have, but test whether userProp Is Nothing before you do anything with it. If it is Nothing, then add the property.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Vbasiccode said:
so should i replace the line
userProp = newAccount.UserProperties.Find("Carrier")
with
userProp = itemContact.UserProperties.Add("Carrier", olText)

for each of the properties in the Form Region?

Sue Mosher said:
The symptoms suggest that the property doesn't exist on the item yet. You'll need to add it using the UserProperties.Add method if it doesn't already exist on the individual item.

This isn't a problem when the user opens the item, because opening it invokes the form region, which causes the necessary properties to be created.

Vbasiccode said:
I have created a new Region (seperate type). I now want ot communicate with
that form from an outside windows application. when i run the code shown
below, i get an error because it can't find the user properties that the code
is requesting. However if i open up the Account form then the actual new
region form, then suddenly all the user properties are available.

Is their a way to communicate with the regions (seperate type) User
properties (UDFs) with out having to open the matching form in out look
itself?

Dim app As New Outlk.Application
Dim olns As Outlk.NameSpace = app.GetNamespace("MAPI")
Dim olFolders As Outlk.Folders = olns.Session.Folders
Dim RootFolder As Outlk.Folder = olFolders("Business Contact Manager")
Dim AccountsFldr As Outlk.Folder = RootFolder.Folders("Accounts")
Dim newAccount As Outlk.ContactItem = Nothing
Dim userProp As Outlk.UserProperty = Nothing


newAccount = AccountsFldr.Items.Find("[Subject]='Account2 Name'")

'the error occures on this line because it cannot find the UDF Called
Carrier
userProp = newAccount.UserProperties.Find("Carrier")
 
Top