M
Miguel Lopes
Hi,
I am developing a Outlook 2003 Add In, using Visual Studio 2005 and Shared
Add In project template with C#.
The Primary Interop Assemblies for Office 2003 are also installed.
The goal of the addin is to provide the user that sends an email the ability
to save it to disk. For that i am trapping the ItemSend
event as follows:
public void OnConnection(object application, Extensibility.ext_Co....
{
.....
Outlook._Application obj = (Outlook._Application)application;
obj.Application.ItemSend += new
ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
.....
}
In order to provide user interaction with the addin, i added to the project
a standard Windows Form ( WhereToSaveForm.cs )
and in the addin event handler code i put the following code:
MessageBox.Show("Saving");
WhereToSaveForm formSave = new WhereToSaveForm();
formSave.ShowDialog();
In order to test, i just added a button to the form, with a click event
handler, that justs closes the form:
this.Close();
When i send an email the following happen:
1) The message box is shown, saying: "Saving";
2) The form is loaded and shown;
3) Click on form button;
4) The form is closed;
5) Email is sent;
But when i repeat the procedure ( without closing Outlook ):
1) The message box is not shown;
2) The form is not loaded and obviously not shown;
3) The email is sent;
It seems that for some reason my addin gets unloaded or somehow the event
handler is not invoked.
I tracked down the problem to the following line:
formSave.ShowDialog();
if i comment this line, the event is always called, no matter how many
messages are sent ( the message box is always shown ).
In order to discover the problem i tested the following:
1) See if any exception was thrown that could cause the add in to unload -
No exception was thrown;
2) Try to reproduce the implementation of the message box, since with
MessageBox object the event is always fired - Without success;
3) Use Dispose() and Close() from the addIn ItemSend event handler, to get
the form closed - Without success;
Any ideas on this odd behavior?
Best Regards,
Miguel Lopes
I am developing a Outlook 2003 Add In, using Visual Studio 2005 and Shared
Add In project template with C#.
The Primary Interop Assemblies for Office 2003 are also installed.
The goal of the addin is to provide the user that sends an email the ability
to save it to disk. For that i am trapping the ItemSend
event as follows:
public void OnConnection(object application, Extensibility.ext_Co....
{
.....
Outlook._Application obj = (Outlook._Application)application;
obj.Application.ItemSend += new
ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
.....
}
In order to provide user interaction with the addin, i added to the project
a standard Windows Form ( WhereToSaveForm.cs )
and in the addin event handler code i put the following code:
MessageBox.Show("Saving");
WhereToSaveForm formSave = new WhereToSaveForm();
formSave.ShowDialog();
In order to test, i just added a button to the form, with a click event
handler, that justs closes the form:
this.Close();
When i send an email the following happen:
1) The message box is shown, saying: "Saving";
2) The form is loaded and shown;
3) Click on form button;
4) The form is closed;
5) Email is sent;
But when i repeat the procedure ( without closing Outlook ):
1) The message box is not shown;
2) The form is not loaded and obviously not shown;
3) The email is sent;
It seems that for some reason my addin gets unloaded or somehow the event
handler is not invoked.
I tracked down the problem to the following line:
formSave.ShowDialog();
if i comment this line, the event is always called, no matter how many
messages are sent ( the message box is always shown ).
In order to discover the problem i tested the following:
1) See if any exception was thrown that could cause the add in to unload -
No exception was thrown;
2) Try to reproduce the implementation of the message box, since with
MessageBox object the event is always fired - Without success;
3) Use Dispose() and Close() from the addIn ItemSend event handler, to get
the form closed - Without success;
Any ideas on this odd behavior?
Best Regards,
Miguel Lopes