简体   繁体   中英

How to add bitmap image in outlook custom column

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM