Board index » delphi » Outlook Com - Shuts down after connect

Outlook Com - Shuts down after connect

I am using Delphi 5 and the code below to send Emails via Outlook
2000.

Why is it that after I connect to an already running Outlook2000 app
(started from W2000), and, after executing the code below, the
Outlook2000 app shuts down?
Since it was started from Windows should the refrence count be at 2
after the code below executes,  then back to 1 after completion which
will cause it to remain active?

I would expect that the Outlook app should be shut down only if it was
started from the code below?

Any help is appreciated .
Thanks
Gabe.

var
  Unknown: IUnknown;
  Result: HResult;
  Folder  : MAPIFolder;
  Outlook,  MailItem : OleVariant;
begin
  Outlook := CreateOleObject('Outlook.Application');
  MailItem := Outlook.CreateItem(olMailItem);
  MailItem.Subject := sSubject;
  MailItem.Body    := sBody;
  MailItem.Recipients.Add(sRecipient);
  MailItem.Send;

 

Re:Outlook Com - Shuts down after connect


<<Gabe:
Why is it that after I connect to an already running
Outlook2000 app (started from W2000), and, after executing
the code below, the Outlook2000 app shuts down?

Quote

Doesn't happen with Outlook started normally. How are you
starting Outlook, exactly?

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Outlook Com - Shuts down after connect


"Deborah Pate (TeamB)" <d.p...@cableinet.co.not-this-bit.uk> wrote in
<VA.00000301.00f89...@cableinet.co.not-this-bit.uk>:

Quote
><<Gabe:
>Why is it that after I connect to an already running
>Outlook2000 app (started from W2000), and, after executing
>the code below, the Outlook2000 app shuts down?

>Doesn't happen with Outlook started normally. How are you
>starting Outlook, exactly?

Well it does happen, also when outlook started normally.
I'm having the exact same problem I've tried bought BCB 5,
that didn't help, i tried both Win98 and Win2000. Office97
and 2000. I've also posted numerous times to the newsgroups
but i only get 'Doesn't shut down with me' for answer :)

Here's what i'm trying to do:
When my program starts i want to read in the current opened
contact in outlook. I can do that, but when my application
is closed Outlook also closes. That really sucks because the
users have to restart it again. I've created a work-around by
adding a log-item to the Outlook->Memo field so when outlook
tries to shutdown it ask for confirmation to quit without
saving the changes. The user has to click on cancel and then
outlook keeps running.

PLEASE HELP ME WITH THIS PROBLEM. I'M ON THE EDGE OF NERVOUS BREAKDOWN!!!
hehe. just kidding, but i've been looking for a way to solve
it for almost a year now...

Floris Looyesteyn,
The Netherlands.

Re:Outlook Com - Shuts down after connect


Try moving your Outlook var Outside of the method ie scoped to the app.

Paul

Quote
"Gabe" <grech...@ftsinc.com> wrote in message

news:3ad36c9e.84541814@forums.inprise.com...
Quote
> I am using Delphi 5 and the code below to send Emails via Outlook
> 2000.

> Why is it that after I connect to an already running Outlook2000 app
> (started from W2000), and, after executing the code below, the
> Outlook2000 app shuts down?
> Since it was started from Windows should the refrence count be at 2
> after the code below executes,  then back to 1 after completion which
> will cause it to remain active?

Re:Outlook Com - Shuts down after connect


I start outlook from the Windows Start Menu, Also, if i happened to
have several instances of outlook running it will shut them all down.
Gabe

On Wed, 11 Apr 2001 13:18:26 +0100, "Deborah Pate (TeamB)"

Quote
<d.p...@cableinet.co.not-this-bit.uk> wrote:
><<Gabe:
>Why is it that after I connect to an already running
>Outlook2000 app (started from W2000), and, after executing
>the code below, the Outlook2000 app shuts down?

>Doesn't happen with Outlook started normally. How are you
>starting Outlook, exactly?

>--
>Deborah Pate (TeamB) http://delphi-jedi.org

>  Use Borland servers; TeamB don't see posts via ISPs
>  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads