change outlook MailItem icon

依然范特西╮ 提交于 2019-12-06 01:35:27

问题


I'm developing an outlook 2010 addin that exports the emails to a specific locations when an user clicks a button from the menu.

This part is not a problem, but I need also to change the MailItem icon-pictogram if the export was successful. I tried to look for solutions, but I only get that I need to use form regions , but I didn't find a true helpful solution.

Any ideas how should I use this form regions?!


I finished the add-in and everything seems to work perfect when debugging from VS 2010. I also created an installer, but after installing the application the Outlook won't display my icons like I want. Instead of showing what you can see above, it changes the icons, but shows a default one - not mine. The icons are in the resx file from the FormRegion that I used (I use dor default and read icons from manifest) , I also tried to move them to the general Resource file (Properties.Resource), but the result is the same. Can someone help me with this?


So I added a FormRegion using Replacement and ReplaceAll also, added my icon on default icon on manifest, and name it IPM.Note.MyExportedItem.

In the ThisAddin.cs I have the following code:

MailItem mailItem = (selectedItem as MailItem);

                    itemGuid = mailItem.EntryID;
                    string name = mailItem.Subject + ".msg";



                    name = "C:\\" + name.Replace(":", "");
                    try
                    {
                        mailItem.SaveAs(name, OlSaveAsType.olMSG);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    mailItem.MessageClass = "IPM.Note.MyExportedItem";
                    mailItem.Display(true);

                    ........

But this is not changing the mailItem (email message) icon from Inbox for example to my icon when I export them like I want, the only change that I can see is when I call Display(true) and it opens the mail message. Also if I press New Items, Choose Form and I open my Form Region, it opens a compose message window and if I send an email to me, then it will have my icon...strange...you can see in the picture :-) Do you have any idea what I am doing wrong?

Regards


回答1:


Here are the steps required to use custom icons within Outlook:

  1. You need to assign a custom MailItem.MessageClass (IPM.Note.MyCompany.MyExportedItem) to your exported items.
  2. Create a replacement Form Region matching the MessageClass
  3. Assign the Icons in the Properties Pane of the Form Region Designer.
  4. Re-deploy your VSTO Add-In with the Custom Form Region.

This MSDN forum post also describes the process.



来源:https://stackoverflow.com/questions/11115934/change-outlook-mailitem-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!