Using a PropertyAccessor custom datetime property in Views

  • Thread starter Thread starter wclarke101
  • Start date Start date
W

wclarke101

Hello,

I'm having problems getting a datetime property (added using
PropertyAccessor) to display as a column in a customised View.

I've added the datetime property to the PropertyAccessor using the following
code...

objMailItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/DocumentDate", dtDocumentDate)

....where dtDocumentDate is a Date variable.

I've then tried to customise the folder's View to show this custom property
as a column. This is the XML excerpt...

<column>
<type>datetime</type>
<heading>DocumentDate</heading>
<prop>http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/DocumentDate</prop>
<width>200</width>
<style>padding-left:3px;;text-align:left</style>
<editable>1</editable>
<format>M/d/yyyy||h:mm tt</format>
<displayformat>2</displayformat>
</column>

.... but the when I run the application, the this DocumentDate column just
displays the word "None".

If i changed the XML to use a string column instead of a datetime column,
then it displays the date, but the column sorting doesn't work properly
because Outlook is treating the values as strings.

How do i reference a custom datetime property in the View XML? Any help
would be greatly appreciated.

I'm using VSTO with Outlook 2007.

Thanks,
Wayne.
 
Thanks Ken.

How do I add a PT_SYSTIME custom property to PropertyAccessor that would
then display as a date/time column in the grid?

Do you have sample code for the SetProperty method call and the XML column
tag I would need?

Thanks,
Wayne.
 
Why not just use the UserProperties collection?

The http://schemas.microsoft.com/mapi/id/ PropertyAccessor namespace does
take a GUID, but it also requires a property tag. You couldn't refer to the
property by name, since it wouldn't have a name but a property tag.
Unfortunately there is no GetIDsFromNames() method in the object model that
would allow using a name and deriving a MAPI property tag from it.

You would use something like this, given that a PT_SYSTIME has the property
tag OR'd with 0x0040. This example uses an id value picked at random,
0x8502:

Const Custom_Tag =
"http://schemas.microsoft.com/mapi/id/{FFF40745-D92F-4C11-9E14-92701F001EB3}/85020040"

Note that the const should be all on one line as a continuous string. The
GUID is the same as your custom namespace GUID and the id part is composed
of the 0x8502 value I selected at random and the 0x0040 value for a
PT_SYSTIME.

You would use that const with your call to PropertyAccessor.SetProperty()
and in your view XML. That should be the only change needed in the view XML.
 
Back
Top