> I wrote a C# COM add-in based on the sample from MSDN.
> In OnConnection() I sign up for the
[quoted text clipped - 15 lines]
> Is this a known issue? if so, is there anything I can do
> to solve it?
To all of you who have bad experiences with Outlook COM Add-ins written in C#, few adivces:
- GarbageCollector trashes your dispatchers (aka eventHandlers - they represent more, but we stick to the basiscs) so keep fields in your addin as references to both event issuer object and eventHandler object as long as needed. If you don't do this, most of the times you'll end up asking yourself why Outlook doesn't fire events such as itemAdd (from Folder.Items collection) or why newInspector (from Application.Inspectors collection) doesn't fire all the times.
- If you want to make transparent icons in Office 2000 (including Outlook 2000) watch out this sniplet:
Bitmap bmpRes= do what you have to do to get a 16x16 bitmap as the icon, with the top-right corner pixel as the transparent color of the icon;
bmpRes.MakeTransparent(bmpRes.GetPixel(0, 0));
if (bmpRes != null)
{
Bitmap bmpNew= new Bitmap(16, 16);
Graphics g = Graphics.FromImage(bmpNew);
g.FillRectangle(new SolidBrush(SystemColors.Control), 0, 0, 16, 16);
g.DrawImage(bmpRes, 0, 0);
Clipboard.SetDataObject(bmpNew);
btn.FaceId = 0;
btn.PasteFace();
}
There is a hard way to deal with this, but both examples use Windows API calls (a VB and a C++ version) which are somewhat not recomanded directly in .NET platform (it can be done though, if you realy want to)
For OfficeXP and 2003, you will use Picture and Mask properties, no problem there.
- All the collections have a 1 based index, so getting the first item in a items collection would be items.item(1)
Thank to Dmitry Streblechenko and Ken Slovak. They have both been helpful to me these days.