Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change outlook MailItem icon

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?

This is how it looks

Regards

like image 444
Mircea R Avatar asked Jun 20 '12 08:06

Mircea R


People also ask

How do I get the envelope icon in Outlook?

Click on the "Tools" menu in Outlook and select "Options." Under Preferences, click "Email Options," then "Advanced Email Options." Check "Show an envelope icon in the notification area" to restore the icon.

How do I get new email icon on taskbar?

File-> Options-> section Mail-> option group: Message arrival-> option: Show an envelope icon in the taskbar.


1 Answers

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.

like image 66
SliverNinja - MSFT Avatar answered Sep 22 '22 02:09

SliverNinja - MSFT