Reputation: 10648
I am trying to create a new column in explorer. I would like this column to contain one of the predefined Outlook icons using PR_ICON_INDEX.
So I am looping over all Outlook mail items and set their property PR_ICON_INDEX using below method:
private const int OL_PHONE = 0x15D;
private const string PR_ICON_INDEX = "http://schemas.microsoft.com/mapi/proptag/0x10800003";
private bool SetExtendedPropertyValue(Outlook.MailItem aMailItem, string aProperty, int value)
{
Outlook.PropertyAccessor oPropAcc = null;
try
{
oPropAcc = aMailItem.PropertyAccessor as Outlook.PropertyAccessor;
oPropAcc.SetProperty(aProperty, value);
return true;
}
catch (System.Exception ex)
{
//Put your own logging here
}
finally
{
if (oPropAcc != null)
{
Marshal.ReleaseComObject(oPropAcc);
oPropAcc = null;
}
}
return false;
}
For example, in some point in my code I call this method like below:
SetExtendedPropertyValue(mi, PR_ICON_INDEX, OL_PHONE);
Also I have replaced the active explorer CurrentView.XML with a custom view but when I call to CurrentView.Apply() after setting the XML I get below exception:
The operation failed
The custom view I am trying to set is below (not working):
<?xml version="1.0"?>
<view type="table">
<viewname>myView</viewname>
<viewstyle>table-layout:fixed;width:100%;font-family:Segoe UI;font-style:normal;font-weight:normal;font-size:8pt;color:Black;font-charset:0</viewstyle>
<viewtime>0</viewtime>
<linecolor>8421504</linecolor>
<linestyle>3</linestyle>
<previewlines>1</previewlines>
<previewlineschangenum>1</previewlineschangenum>
<ensuredcategoriesfield>1</ensuredcategoriesfield>
<collapsestate/>
<rowstyle>background-color:White;color:Black</rowstyle>
<headerstyle>background-color:#D3D3D3</headerstyle>
<arrangement>
<autogroup>1</autogroup>
<enablexfc>1</enablexfc>
<collapseclient/>
<collapseconv/>
<upgradetoconvchangenum>1</upgradetoconvchangenum>
</arrangement>
<column>
<name>HREF</name>
<prop>DAV:href</prop>
<checkbox>1</checkbox>
</column>
<column>
<heading/>
<prop>http://schemas.microsoft.com/mapi/id/{00020328-0000-0000-C000-000000000046}/8ff00003</prop>
<type>i4</type>
<width>1190</width>
<style>padding-left:3px;text-align:left</style>
<editable>0</editable>
<displayformat>3</displayformat>
<userheading/>
</column>
<column>
<heading>Categories</heading>
<prop>urn:schemas-microsoft-com:office:office#Keywords</prop>
<width>50</width>
<sortable>0</sortable>
<style>text-align:left;padding-left:3px</style>
<editable>1</editable>
</column>
<column>
<heading>Mention</heading>
<prop>urn:schemas-microsoft-com:office:outlook#at-me-flag</prop>
<type>boolean</type>
<autoresize>0</autoresize>
<width>50</width>
<sortable>0</sortable>
<style>text-align:center;padding-left:3px</style>
<editable>0</editable>
<format>boolicon</format>
<displayformat>3</displayformat>
</column>
<column>
<heading>Status</heading>
<prop>http://schemas.microsoft.com/mapi/proptag/0x10800003</prop>
<bitmap>1</bitmap>
<style>padding-left:3px;;text-align:center</style>
<editable>0</editable>
</column>
<groupbydefault>2</groupbydefault>
<previewpane>
<visible>1</visible>
<markasread>0</markasread>
</previewpane>
</view>
However below XML view is working:
<?xml version="1.0"?>
<view type="table">
<viewname>myView</viewname>
<viewstyle>table-layout:fixed;width:100%;font-family:Segoe UI;font-style:normal;font-weight:normal;font-size:8pt;color:Black;font-charset:0</viewstyle>
<viewtime>0</viewtime>
<linecolor>8421504</linecolor>
<linestyle>3</linestyle>
<previewlines>1</previewlines>
<previewlineschangenum>1</previewlineschangenum>
<ensuredcategoriesfield>1</ensuredcategoriesfield>
<collapsestate/>
<rowstyle>background-color:White;color:Black</rowstyle>
<headerstyle>background-color:#D3D3D3</headerstyle>
<arrangement>
<autogroup>1</autogroup>
<enablexfc>1</enablexfc>
<collapseclient/>
<collapseconv/>
<upgradetoconvchangenum>1</upgradetoconvchangenum>
</arrangement>
<column>
<name>HREF</name>
<prop>DAV:href</prop>
<checkbox>1</checkbox>
</column>
<column>
<heading/>
<prop>http://schemas.microsoft.com/mapi/id/{00020328-0000-0000-C000-000000000046}/8ff00003</prop>
<type>i4</type>
<width>1190</width>
<style>padding-left:3px;text-align:left</style>
<editable>0</editable>
<displayformat>3</displayformat>
<userheading/>
</column>
<column>
<heading>Categories</heading>
<prop>urn:schemas-microsoft-com:office:office#Keywords</prop>
<width>50</width>
<sortable>0</sortable>
<style>text-align:left;padding-left:3px</style>
<editable>1</editable>
</column>
<column>
<heading>Mention</heading>
<prop>urn:schemas-microsoft-com:office:outlook#at-me-flag</prop>
<type>boolean</type>
<autoresize>0</autoresize>
<width>50</width>
<sortable>0</sortable>
<style>text-align:center;padding-left:3px</style>
<editable>0</editable>
<format>boolicon</format>
<displayformat>3</displayformat>
</column>
<groupbydefault>2</groupbydefault>
<previewpane>
<visible>1</visible>
<markasread>0</markasread>
</previewpane>
</view>
The difference between both XML views is the following (first view has defined below column and the second hasn't):
<column>
<heading>Status</heading>
<prop>http://schemas.microsoft.com/mapi/proptag/0x10800003</prop>
<bitmap>1</bitmap>
<style>padding-left:3px;;text-align:center</style>
<editable>0</editable>
</column>
So the problem comes with above column definition. It refers to the property PR_ICON_INDEX. It looks like there is something that Outlook does not like.
So what am i doing wrong?
Upvotes: 0
Views: 181
Reputation: 66255
Look at what Outlook itself is using:
<column>
<heading>Icon</heading>
<prop>http://schemas.microsoft.com/mapi/proptag/0x0fff0102</prop>
<bitmap>1</bitmap>
<width>18</width>
<style>padding-left:3px;;text-align:center</style>
<editable>0</editable>
</column>
Upvotes: 1