Outlook process does not close

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

Outlook process does not close
 
Thanasis Boukouvalas




Posts: 40
Joined: 2006-06-17
Hi

I have a test add-in with temporary explorer and inspector command bars (for mail), one option page and one folder properties page (for mail folders).
This add-in has no code at all. Just the auto generated code.

I also have a test project that send a mail with the following code:


    Dim otl As New Outlook.Application
    Dim ns As Outlook.NameSpace = otl.GetNamespace("MAPI")
    Dim mail As Outlook.MailItem

    ns.Logon(, , True, True)
    mail = CType(otl.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
    With mail
      .To = "tbo"
      .Subject = "?"
      .Body = "???"
      .Send()
    End With

    System.Runtime.InteropServices.Marshal.ReleaseComObject(mail)
    System.Runtime.InteropServices.Marshal.ReleaseComObject(ns)
    System.Runtime.InteropServices.Marshal.ReleaseComObject(otl)


I'm doing the following two tests with Outlook closed.

1. Addin is NOT installed: the above code starts Outlook and after sending email the Outlook process is terminated.
2. Addin is installed: the above code starts Outlook process and then I have to terminate it with windows task manager.
3. Addin is installed: I'm starting Outlook and then close it. Outlook process is terminated.

What I'm doing wrong?
Posted 20 Oct, 2006 11:11:12 Top
Thanasis Boukouvalas




Posts: 40
Joined: 2006-06-17
Now, I have an even worst case: "Call was rejected by callee".

After the above
1. I've stoped the Outlook with task manager and the exe that sends email.
2. I'm starting the exe again and try to send email. Now I'm taking "Call was rejected by callee" at line "Dim otl As New Outlook.Application" !?

If add-in is not installed then sending email with this exe has no any problem.

Please help me. I cannot understand why this simple task was failed.



See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80010001): Call was rejected by callee.
at Entersoft.Framework.Mail.Form1.SendMail(String toVal, String subjectVal, String bodyVal) in C:\ESDev.CRM\Tests\Issue7\SendMail\Form1.vb:line 12
at Entersoft.Framework.Mail.Form1.Button1_Click(Object sender, EventArgs e) in C:\ESDev.CRM\Tests\Issue7\SendMail\Form1.vb:line 88
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2359
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
Outlook
Assembly Version: 1.0.2487.18863
Win32 Version: 1.0.2487.18863
CodeBase: file:///C:/Documents%20and%20Settings/tbo/Desktop/SendMail/Outlook.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
Microsoft.Office.Interop.Outlook
Assembly Version: 10.0.4504.0
Win32 Version: 10.0.4504
CodeBase: file:///C:/Documents%20and%20Settings/tbo/Desktop/SendMail/Microsoft.Office.Interop.Outlook.DLL
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.


Posted 23 Oct, 2006 04:40:38 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Thanasis.

I know about this issue.
I think that Outlook hangs because an instance of a newly created mail is not released in the 'Marshal.ReleaseComObject(mail)' code. For some reason the mail interface is not valid after you send the email via the code. I tested this situation with Outlook not closing but I did it using the unmanaged C++ application for sending emails. The C++ code worked fine. I suppose that was because the C++ code worked faster than the .NET code. Now I am trying to find a solution and will let you know about results soon.
Posted 23 Oct, 2006 10:00:45 Top