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
Here are the steps required to use custom icons within Outlook:
- You need to assign a custom
MailItem.MessageClass
(IPM.Note.MyCompany.MyExportedItem) to your exported items. - Create a replacement Form Region matching the
MessageClass
- Assign the Icons in the Properties Pane of the Form Region Designer.
- Re-deploy your VSTO Add-In with the Custom Form Region.
来源:https://stackoverflow.com/questions/11115934/change-outlook-mailitem-icon