Re: PR_USERFIELDS Format



For the record (did anyone expect me not to reply to this?) we would
strongly encourage you NOT to pursue a solution based on this information.
The PR_USERFIELDS property is very complex and also very brittle. Anything
you get wrong is quite likely to cause Outlook to crash.

The Outlook Object Model can be used to add fields...

"Jack Harris" <covinasurf@xxxxxxxxx> wrote in message
news:1131664060.966838.318460@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> In our application we had to add all of our custom fields to the user
> defined fields in certain folders. That meant cracking the
> PR_USERFIELDS format.
>
> I thought I would share this as I can't find any other posts with this
> information posted, so here goes.
>
> It's similar to other list structures Outlook uses, such as
> FLATENTRYLIST.
>
> typedef struct _USERPROPLIST
> {
> ULONG cbEntries; // Number of entries in the list
> USERPROP userProps[MAPI_DIM];
> } USERPROPLIST;
>
> typedef struct _USERPROP
> {
> ULONG ulType; // Type of the field
> USHORT cbLength; // Length of the name string
> TCHAR lpName[MAPI_DIM]; // Name of the named prop
> GUID propSet; // Prop set of the named prop
> ULONG ulFormatId; // Format Id, or something?
> BYTE btFormat[18]; // Array specifing the format to use
>
> } USERPROP;
>
> Note that USERPROP has a variable sized array right in the middle -
> which really makes this unusable as a struct, but it's a good
> illustration. If the record is blank, it isn't there at all. More on
> that below.
>
> Now for the fun part - there are actully 2 copies of the list, one with
> the name strings in ANSI format and 1 with the name strings in Unicode
> format.
> In addition, each list terminates with a blank record. This record is
> 44 bytes - the size of the USERPROP structure without the name string
> member.Make sure the blank record is accounted for in the record count.
>
> I've figured out most of the fields with the exception of ulFormatId.
> I'm not really sure what this is - it's usually 0x80000007, but I have
> found one exception and there are probably more.
>
> I used Outlook to create some dummy custom fields to get the types and
> format arrays. I only did the ones that we were using, but here what I
> have.
>
> Field Types
> #define FORMAT_TEXT_TYPE 0x01
> #define FORMAT_NUMBER_TYPE 0x0C
> #define FORMAT_YESNO_TYPE 0x06
> #define FORMAT_DATETIME_TYPE 0x05
> #define FORMAT_PERCENT_TYPE 0x0C
> #define FORMAT_CURRENCY_TYPE 0x0E
> #define FORMAT_DURATION_TYPE 0x07
> #define FORMAT_INTEGER_TYPE 0x03
>
> Format Id's
> #define FORMAT_STANDARD_ID 0x80000007
> #define FORMAT_PERCENT_ID 0x81000007
>
> As I said above - the only exception that I found so far was for
> percent type fields.
>
> Format Arrays
> static const BYTE StandardFormat[] = {0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00};
> static const BYTE YesNoFormat[] = {0x02, 0x00, 0x02, 0x00, 0x02, 0x02,
> 0xCC, 0xFD, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00};
> static const BYTE DateTimeFormat[] = {0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
> 0x00};
> static const BYTE PercentFormat[] = {0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
> 0x00};
>
> Again - just have the ones that I was going to use.There are more.
>
> So for the following types of properties (Type/Format) use
> (Type/FormatId/FormatArray):
>
> Text/Text
> FORMAT_TEXT_TYPE
> FORMAT_STANDARD_ID
> StandardFormat
>
> Integer/1,234
> FORMAT_INTEGER_TYPE
> FORMAT_STANDARD_ID
> StandardFormat
>
> Yes/No / Yes/No
> FORMAT_YESNO_TYPE
> FORMAT_STANDARD_ID
> YesNoFormat
>
> Data/Time / Thu 11/10/2005 4:00 PM
> FORMAT_DATETIME_TYPE
> FORMAT_STANDARD_ID
> DateTimeFormat
>
> Number/2 Decimal
> FORMAT_NUMBER_TYPE
> FORMAT_STANDARD_ID
> StandardFormat
>
> Percent/2 Decimal
> FORMAT_PERCENT_TYPE
> FORMAT_PERCENT_ID
> PercentFormat
>
> Currency/$12.345.60
> FORMAT_CURRENCY_TYPE
> FORMAT_STANDARDE_ID
> StandardFormat
>
> Jack Harris
> Seminars and Systems
>


.