0
votes

I want to add custom image column in outlook view. This is my sample code to add custom icon.

   Outlook.Explorer explorer = this.Application.ActiveExplorer();
                Outlook.Selection selection = null;
                try { selection = explorer.Selection; }
                catch { }
                if (selection != null && selection.Count > 0)
                {
                    object item = selection[1];
                    if (item is Outlook.MailItem)
                    {
                        Outlook.MailItem mail = item as Outlook.MailItem;
                        Outlook.UserProperties userProperties = mail.UserProperties;
                        Outlook.UserProperty userProperty = userProperties.Add("SyncStatus", Outlook.OlUserPropertyType.olEnumeration, true, Outlook.OlFormatEnumeration.olFormatEnumBitmap);
                        userProperty.Value = new Bitmap(@"...\icons\Sync.ico");
                        mail.Save();
                        Marshal.ReleaseComObject(userProperty);
                        Marshal.ReleaseComObject(userProperties);
                    }
                    Marshal.ReleaseComObject(item);
                    Marshal.ReleaseComObject(selection);
                }

Error: An exception of type 'System.Runtime.InteropServices.COMException' occurred in XXXXXX.dll but was not handled in user code

Additional information: Data type is not supported.

Please suggest how can i add image column in outlook.

1

1 Answers

0
votes

You cannot do that. Even though you can add binary data, Outlook does not parse it in any way and will not use it to show any kind of an image.