Michael Swanson
Posts: 1
Joined: 2006-07-06
|
I have an addin that will reply to certain mails that contain certain named properties. I can add named properties without any problems.
The code coes something like this:
OnNewInspector()
{
if named property exists
{
then create new mail
set named properties
// commented out mailItem.Save()
send
closeInspector = 2;
}
}
At this point, I would like to close the Current Inspector that the user opened after double-clicking on the mail, and then delete the mail. Through trial and error, I found that I needed to close the inspector TWICE and delete the mail. I seemed to have no choice but to put this in the OnInspectorActivate()
So, the hack that followes:
OnInspectorActivate
{
while (closeInspector > 0)
close inspector
if (closeInspector == 1)
mail.delete()
closeInspector--;
}
Everything works good at this point.
The problem is when I close Outlook, a Word window with no message is displayed and it prompts me to save the contents (there is no contents). I found through more trial and error that I needed to save the mailItem after setting named properties. So I commented out the Save() line in OnNewInspector().
Now the problem is that a zombie mailItem with no Receiptant is saved in the Outbox. The real mailItem is sent fine.
So, is there a special order in which an Inspector should be closed in regards to deleting a mailItem?
Thank you for any help. I've been spending many hours trying to fix this. |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Michael.
I think you shouldn't delete a mail item in the InspectorActivate event. Try to use the OnSendMessage event of the AddinModule class to delete it. You will have to send a message using the SendMessage method of the AddinModule class so that the OnSendMessage event will fire.
e.g
OnInspectorActivate
{
.....
this.SendMessage(MYMESSAGE, IntPtr.Zero, IntPtr.Zero);
.....
}
|
|