Thomas

Thomas

  • NA
  • 41
  • 0

Custom value in custom column in outlook 2013 inbox view

Jan 9 2015 2:45 AM

Hi all

I have the following code that adds a new custom column ("NewColumn") to the outlook inbox. My question is the following: Is it possible to add a custom value to this new column? The value should be saved to the specific mail, and different custom values should be added to different mails in the inbox.

Best regards and thanks in advance
/Thomas
 

Outlook.Explorer currExplorer = null;

Outlook.MAPIFolder currFolder = null;

Outlook.Views views = null;

Outlook.TableView tableView = null;

Outlook.ViewFields viewFields = null;

Outlook.ViewField viewField = null;

Outlook.ColumnFormat columnFormat = null;

Outlook.UserDefinedProperties userProperties = null;

Outlook.UserDefinedProperty billableProperty = null;

try

{

currExplorer = Application.ActiveExplorer();

currFolder = currExplorer.CurrentFolder;

userProperties = currFolder.UserDefinedProperties;

billableProperty = userProperties.Add("NewColumn", Outlook.OlUserPropertyType.olYesNo);

views = currFolder.Views;

views.Remove("My Custom View");

tableView = (Outlook.TableView)views.Add("My Custom View", Outlook.OlViewType.olTableView, Outlook.OlViewSaveOption.olViewSaveOptionThisFolderEveryone);

viewFields = tableView.ViewFields;

viewField = tableView.ViewFields.Add("NewColumn");

columnFormat = viewField.ColumnFormat;

columnFormat.Align = Outlook.OlAlign.olAlignCenter;

tableView.Save();

tableView.Apply();

}

finally

{

if (userProperties != null)

Marshal.ReleaseComObject(userProperties);

if (billableProperty != null)

Marshal.ReleaseComObject(billableProperty);

if (viewFields != null)

Marshal.ReleaseComObject(viewFields);

if (viewField != null)

Marshal.ReleaseComObject(viewField);

if (columnFormat != null)

Marshal.ReleaseComObject(columnFormat);

if (tableView != null)

Marshal.ReleaseComObject(tableView);

if (views != null)

Marshal.ReleaseComObject(views);

if (currFolder != null)

Marshal.ReleaseComObject(currFolder);

if (currExplorer != null)

Marshal.ReleaseComObject(currExplorer);

}