Hi Ken,
I'm calling outlook 2003 from a c# console program, no service (but good to
know it would not work from one).
The garbage collector I could try, thanks - but shouldn't the .net runtime
dispose of objects when quitting the program?
The source I'm using:
--
Outlook.Application outlookApp = new Outlook.Application();
Outlook.NameSpace outlookNamespace = outlookApp.GetNamespace("mapi");
outlookNamespace.Logon("", "", true, true);
Outlook.MAPIFolder outlookKontaktFolder = outlookNamespace.PickFolder();
try
{
foreach (EinKunde kd in kunden.Values)
{
Outlook.ContactItem newItem =
(Outlook.ContactItem)outlookKontaktFolder.Items.Add("IPM.Contact");
// set fields in new item
newItem.Close(Outlook.OlInspectorClose.olSave);
}
}
finally
{
outlookNamespace.Logoff();
outlookApp.Quit();
}
--
After the 250 new object the client session will close, Logoff and Quit will
be called, the program will end, but outlook will stay active and can't be
closed.
Sam
"Ken Slovak" <(E-Mail Removed)> wrote:
> Is this from an EXE or a service and what language are you using? What
> version of Outlook?
>
> If a service, find some other way to do it. Outlook cannot be run from a
> service.
>
> If from .NET explicitly call the garbage collector.
>
> Otherwise provide more details on your setup and maybe show some of your
> code. You are handling any possible errors?
>
> --
> 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
>
>
> "Sam Jost" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi folks,
>>
>> I'm running outlook via com, importing and changing lots of public data.
>> Sometimes I hit some boundary and get an exception a client task has
>> failed. Thats not the problem I want to ask about.
>>
>> The problem is: after I got this exception I try to gracefully close
>> outlook using
>> outlookNamespace.Logoff();
>> outlookApp.Quit();
>>
>> It does not close. Well, the main window does close, but outlook stays in
>> taskbar and task manager, and I can't get it to close other then to kill
>> the process. Outlook keeps saying it is busy with some task to exchange
>> (probly the failing one) and wont budge.
>>
>>
>> My question is: how do I (gracefully) get outlook to stop the failed
>> client task, close the connection and quit?
>>
>> it does quit nicely whenever I don't get a client exception, but it must
>> be possible to somehow gracefully close outlook when I have hit an
>> exception, not?
>>
>> thanks,
>> Sam
>>
>