View Single Post
  #10  
Old January 14th 08, 09:37 PM posted to microsoft.public.outlook.program_addins
Bob Martin
external usenet poster
 
Posts: 1
Default Empty UserProperties and PropertyAccessor ( Outlook Spy )

I have encountered the same problem identified by Jeff. I am using Visual
Basic to interact with a FormRegion on a Contact form. I created four
UserProperty fields in the FormRegion by dragging them from the Field
Chooser, with the filter set to "UserProperties in this folder" (so I know
the problem is not due to the UserProperties not having been added to the
Contact folder). I have written a dialog which, based on user input to the
dialog, in code sets the UserProperties in the FormRegion. I have tried
setting each UserProperty directly:

Dim oProp As Outlook.UserProperty
Set oProp = ContactItem.UserProperties.Find("Group")
oProp.Value = strGroup

and also tried setting each UserProperty by manipulating the text box in the
FormRegion that displays the UserProperty:

olkGroup.Value = strGroup

Either way, the UserProperties are saved in the ContactItem and are
redisplayed when I reopen the Contact form. However, when I access the
ContactItem in code (i.e., without opening the Contact form), the
UserProperties.Count is 0 and UserProperties.Find cannot find any
UserProperties.

Jeff's workaround solves the problem. Before setting the UserProperties in
the FormRegion in an open Contact form, I do the following:

oItem.UserProperties.Add "Bogus", olText
oItem.UserProperties.Find("Bogus").Delete

After I do that, when I access the ContactItem in code, the ContactItem
returns the correct UserProperties.Count, and UserProperties.Find retrieves
the UserProperties.

"Jeff" wrote:

Alright.... Using Dmitry Streblechenko's excellent Outlook Spy product I
discovered what the problem was / is.

I modified one of the Contact's using OL's All Properties page and what ya
know... the UserProperties were all saved and accessible via the Item?

So I used Outlook Spy to compare this Contact to one that didn't have the
UserProperties.

The Contact showing the problem was missing the IMAP "UserProperties"
PT_BINARY tag. So, even though all the UserProperties
themselves were stored in the IMAP IMessage Properties, since this
particular tag was missing, accessing the item via the Outlook objects did
not
return the UserProperties collection. I assume the IMAP "UserProperties" tag
is some kind of internal tab used by OL.

It seems ( at least via Native C++ ) if you have a custom Form Region
connected to ContactItem, OL will NOT save the UserProperties collection.
But, you can force it to by adding a "UserProperty" programmatically and
then saving the item ( the workaround ). Oddly, OL WILL save Form Region
generated UserProperties as IMAP Properties in the
{00020329-0000-0000-C000-000000000046} namespace.

I hope my explanation is a little clearer than mud and this helps someone
else.

Personally, I think this behaviour is an Outlook 2007 Form Region related
bug.

Thanks Dmitry!

"Jeff" wrote in message
...

Interestingly, using Outlook Spy, it does not see the UserProperties
either on the contact item, when it is in the folder ( selected ) but DOES
when the item is open in the Form Region ( Outllook 2007 )

Looking at the item useing Outlook Spy's IMessage view, all the properties
are there.

Very Odd...

Any Ideas?




"Jeff" wrote in message
...
Hi All

I've got the following strange problem. Language == C++

I've added custom properties to the containg outlook contact folder and
create the contact item using replacement form regions. Within
the form regions all the custom values are saved and redisplayed every
time you open and close the contact item.

BUT, if I grab the items collection for the folder and access each
contact item, the UserProperties items are "empty". ie: have no value and
a the count for the collection is 0

ie:
_ItemsPtr spItems = NULL;
MAPIFolderPtr spFdr = GetListingsFolder(m_spApp);
if(spFdr){
spItems = spFdr-Items;
}


if(spItems){
_ContactItemPtr spContact;
for(int i=1; i=spItems-Count; i++){
spContact = spItems-Item(i);

UserPropertiesPtr spProps = spContact-UserProperties;
int ic = spProps-Count;

ie:
UserPropertyPtr spProp = spContact-UserProperties-Item("RE MY
Value");
if(spProp ==NULL){
Barf.... Allways...
}

Strangly, I can access most of the custom properties using the
PropertyAccessor:

ie:
PropertyAccessor-GetProperty(http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/RE%20MY%20Value);

But NOT if the custom property is a Currancy value. In the case of
currancy values, I can access them if I have just resaved them using the
form region, but not if Outlook
has been shut down and restarted. :S

It seems to me, that the UserProperties are not being loaded when the
items collection is filled. Is there any way to "Force" the loading of
the UserProperties for each item in the items collection?

Any ideas? Thanks!







Ads