A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Very Odd Behavior - Outlook 2003 AddIn with a Form



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 28th 06, 01:42 PM posted to microsoft.public.outlook.program_addins
Miguel Lopes
external usenet poster
 
Posts: 1
Default Very Odd Behavior - Outlook 2003 AddIn with a Form

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(Applicat ion_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

  #2  
Old June 28th 06, 03:24 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Very Odd Behavior - Outlook 2003 AddIn with a Form

Please don't multipost. See my response in another group you posted in.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Miguel Lopes" wrote in message
...
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(Applicat ion_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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Office 2003 strange behavior Beauford Outlook - General Queries 5 August 1st 06 10:33 PM
Odd Outlook 2003 problem drec Outlook - General Queries 1 June 10th 06 04:49 PM
outlook 2003 wierd behavior Mike Outlook - General Queries 0 May 8th 06 05:46 PM
Odd message in Outlook 2003 when importing .csv [email protected] Outlook - Calandaring 0 March 14th 06 06:27 PM
Odd Behavior Eric Lanyon Outlook - General Queries 1 February 14th 06 08:29 PM


All times are GMT +1. The time now is 09:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.