Contact Inspector: "Save and Close"

Add-in Express™ Support Service
That's what is more important than anything else

Contact Inspector: "Save and Close"
not closing under certain 
Advatel Company




Posts: 11
Joined: 2006-05-15
We have a program created in .NET that pulls contact information out of Outlook and a separate Outlook Add-in made using the Add-In-Express Delphi components.

Our trouble is only occuring when these two programs are running at the same time.
The .NET program opens Outlook by trying to connect to it. (Problem does not happen if Outlook was opened to begin with)
The .NET program calls ContactItem.Display(True);
An Inspector window opens with the contact item inside and the toolbar loads successfully.
We then click on the "Save and Close" button and the window begins to shut down but stops with no contact item inside but the window is still visible and the toolbars can still be used (unsuccessfully though)
Clicking on the "x" to close the window finally closes it.

Do you have any idea why this would be happening? When the .NET program runs without the toolbar the Inspector window closes fine. When the Toolbar is running without the .Net it also closes fine.
Posted 22 Jun, 2006 01:08:41 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi,

From your description I can't tell for sure what happens in this case. You'd better send me some code for testing.

Posted 22 Jun, 2006 12:27:05 Top
Advatel Company




Posts: 11
Joined: 2006-05-15
I believe I may have isolated the problem. It appears that with Outlook 2002 there is a problem with the Messages received from outlook. The Inspector window's Close function is only being called when the window is closed via exit or the "x", it never gets called when "Save and Close" is clicked on, nor if you click "send" or "Delete" on an e-mail... Instead the Item's Close method is called (This is from watching Outlook Spy). This of course means that the following method isn't executed:
procedure TadxAddin.DoInspectorClose(ASender: TObject);


For some reason some of the computers we are testing the toolbar on have e-mail Inspector windows lingering after sending or deleting e-mails, and this is also brought out for Contact Inspectors when using another program connected to outlook.
Posted 25 Jun, 2006 20:49:17 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi,

I have found similar problem description at http://www.pcreview.co.uk/forums/thread-1856025.php where an MVP in Outlook recommends not to use modal forms in such a situation.

Posted 26 Jun, 2006 10:59:19 Top
Advatel Company




Posts: 11
Joined: 2006-05-15
I?Â?Ð?ém not sure if this should be written in a new thread but it seems to be a similar problem except this time it is Inspectors with Mail Items. When an e-mail is sent and sometimes deleted, the window gets left in the Taskbar, but you are unable to do anything with it. If you use word as your editor, there is only one slot ?Â?Ð?ìMicrosoft Windows?Â?Ð?í, if not there is one slot for every e-mail and the titles of each e-mail. An after effect is that other outlook windows will also get stuck here (Send and Receive, Reminders).

I have tracked the error to this line of code in a method of mine:
 BodyText := SelectedItem.Body; 

where BodyText is a WideString and SelectedItem is a MailItem (Passed in as a Parameter). I know it is this line because if I comment it out the problem stops but I need to get the Body to determine if the code should continue.

This method is called by the following:

 procedure TAddInModule.adxCOMAddInModuleOLInspectorActivate(
  Sender: TObject);
var
  Inspector: _Inspector;
  tempStr : string;
  SelectedMail : MailItem;
  SelectedContact : ContactItem;
begin
  if (CmdBarOI.Enabled) and (FActive) then
  begin
    OutputDebugString('Inspector has activated');
    CmdBarOI.Visible := True;
    if Sender is TInspector then
      try
        tempStr := (Sender as TInspector).Caption;
        OutputDebugString(PChar(tempStr));
        Inspector := (Sender as TInspector).DefaultInterface;
      except on EOleException do Inspector := nil;
      end
    else
      Inspector:= nil;
    if Assigned(Inspector) and Assigned(Inspector.CurrentItem) then
    begin
      //Mail item
      if (Inspector.CurrentItem.QueryInterface(IID__MailItem, SelectedMail) = S_OK) then
      begin
        if Assigned(SelectedMail) then 


The problem seems to happen the most after you open an e-mail then try and forward or reply to it. If I put a breakpoint on the line the problem stops?Â?Ð?? I have a feeling it has something to do with reading the contents of another mail item while the other inspector is trying to close down.

Is there anything you can think of that I can do to stop this from happening?
Posted 05 Jul, 2006 02:36:15 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi,

Is there anything you can think of that I can do to stop this from happening?


Looks like you forgot to release one or more COM interfaces that were used in your code. Please check this and if you will have the same problem I will have to look and debug your code. Please let me know about the results in any case. I am very interested.

Posted 05 Jul, 2006 05:37:02 Top
Advatel Company




Posts: 11
Joined: 2006-05-15
if it is possible, I have a cut down version of my code and a sample dll showing the same problems as described above, can I send this to you somehow?
Posted 10 Jul, 2006 00:28:44 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi,

Yes, sure. You can find support email address in the readme.txt file.

Posted 10 Jul, 2006 04:39:00 Top