Outlook hangs in background - application visibility question 
Author Message
 Outlook hangs in background - application visibility question

Hi,

I make extensive use of automation with Outlook 2000 from an Access/VBA
application.  For example, I create an instance of Outlook and open a new
e-Mail message. Now, I have not found a way to make the Outlook application
itself visible, only the inspector containing the newly created message will
show up.

The problem is, after closing that window (e.g. by sending the
message), Outlook will keep running invisibly in the background. The next
time I try to
use Outlook with Automation, it will be likely to cause my calling
application to hang. Even when trying to open Outlook normally from the
Shell, I often experience that nothing happens - the cursor turns to the
arrow with the little hourglass, but Outlook won't show up. In Task manager,
I then see two Outlook (or sometimes several) processes. If I terminate the
earlier one(s), the most recent one shows up immediately.

I have found that I can even reproduce this behavior without any Automation
or pogrammatic intervention by doing the following:

    1. Start Outlook
    2. Hit "Send/Receive"
    3. Close Outlook Application window while still sending/receiving

After Send/Receive finishes, I have an invisible Outlook in the background
which blocks any other Outlook interaction, including simply opening it from
the Desktop, in the manner described above.

I would be happy just to know how to make the application window visible
programmatically, I guess that way I could at least circumvent the problem.

Thanks for any suggestions,

Rupert



Sun, 26 Dec 2004 00:26:16 GMT  
 Outlook hangs in background - application visibility question
Rupert,
Here's some quick code to make a visible Outlook explorer.  When you
instantiate Outlook, you'll find that olApp.Explorers.Count=0, so you
need to add one:

Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon userName, pwd
'Create reference to new explorer
'(this example uses the inbox):
Set myExplorer = olApp.Explorers.Add _
   (olNs.GetDefaultFolder(olFolderInbox))
'Display it:
myExplorer.Display
'At this point you will see the explorer
Set olNs = Nothing
Set olApp = Nothing
'This releases the variables so you can close Outlook
'To do it in code, use:
'olNs.Logoff
'olApp.Quit
'Then set them both equal to nothing

Hope this helps!

--
Robert Dunn
Software Developer
Certiport, Inc.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 26 Dec 2004 04:33:08 GMT  
 Outlook hangs in background - application visibility question
Thanks Robert,

unfortunately, I have not been able to alleviate my problem a lot by making
the explorer visible. When I close that explorer, Outlook still stays
invisible in the background - it seems it won't quit after "messing" with it
through VBA, although I'm careful to close everything and destroy all
references.

So if anyone has insight on the general problem, I would appreciate more
comments.

Rupert



Quote:
> Rupert,
> Here's some quick code to make a visible Outlook explorer.  When you
> instantiate Outlook, you'll find that olApp.Explorers.Count=0, so you
> need to add one:

> Set olApp = CreateObject("Outlook.Application")
> Set olNs = olApp.GetNamespace("MAPI")
> olNs.Logon userName, pwd
> 'Create reference to new explorer
> '(this example uses the inbox):
> Set myExplorer = olApp.Explorers.Add _
>    (olNs.GetDefaultFolder(olFolderInbox))
> 'Display it:
> myExplorer.Display
> 'At this point you will see the explorer
> Set olNs = Nothing
> Set olApp = Nothing
> 'This releases the variables so you can close Outlook
> 'To do it in code, use:
> 'olNs.Logoff
> 'olApp.Quit
> 'Then set them both equal to nothing

> Hope this helps!

> --
> Robert Dunn
> Software Developer
> Certiport, Inc.

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Sun, 26 Dec 2004 05:32:09 GMT  
 Outlook hangs in background - application visibility question
I've run into the same problems myself.  I've found it quite difficult
to release all the objects that belong to outlook.  For some reason, it
seems that Outlook XP has more problems with this than Outlook 2000.
Which one are you using?  Also, are there any add-ins that might be
suspicious, like Redemption (old version had a problem with Outlook XP)
or OutlookSpy?  I've given up on my particular app in Outlook XP and am
just using Outlook 2000 for it now.

--
Robert Dunn
Software Developer
Certiport, Inc.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 26 Dec 2004 06:02:14 GMT  
 Outlook hangs in background - application visibility question
Adding an Explorer in code will not properly set up things for a COM
add-in after you start Outlook using automation. The problem is that
the On_Connection event will have fired already and a properly written
COM add-in will have detected Explorers.Count = 0 AND Inspectors.Count
= 0. It will then refuse to init itself. When the Explorer is added in
code On_Connection does not fire again.

For an example of how to correctly init and shutdown Outlook COM
add-ins you should look at ItemsCB on the Resources page at
www.microeye.com

The only workaround that would work correctly is to add the Explorer
in code and then work with the Application.COMAddins collection. You
have to iterate that collection and toggle the Connect bit for each
COMAddin member to fire On_Connection again:

Dim oCOM As Office.COMAddin
Dim oCOMS As Office.COMAddins

Set oCOMS = olApp.COMAddins
For Each oCOM In oCOMS
    oCOM.Connect = False
    oCOM.Connect = True
Next

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Quote:
> Thanks Robert,

> unfortunately, I have not been able to alleviate my problem a lot by
making
> the explorer visible. When I close that explorer, Outlook still
stays
> invisible in the background - it seems it won't quit after "messing"
with it
> through VBA, although I'm careful to close everything and destroy
all
> references.

> So if anyone has insight on the general problem, I would appreciate
more
> comments.

> Rupert



Sun, 26 Dec 2004 21:09:03 GMT  
 Outlook hangs in background - application visibility question
hm. thank you for the background information, but I am not acutally using
any COM add-in's. I do use Redemption, though, but I don't think that is an
add-in, it's just a dll collection of calls which use the extended MAPI to
emulate Outlook functions. Please correct me if I'm wrong, but I just took a
look at the COMAddins collection of my automated Outlook. It contains only
one item, which is "Microsoft VBA fr Outlook Add-In", even after using
Redemption.

Now, it would help me a lot if I were able to detect an invisible instance
of Outlook in the background and shut it down if necessary. At startup of my
application, I have it check for a running instance of Outlook with
GetObject(Class:="Outlook.Application"). If there is a "dead" Outlook in the
background, my app will hang on that GetObject call until you throw out the
"dead" Outlook process in Task manager.

And again, this seems to be a general problem with Outlook, as you can
easily reproduce it by closing the main application window whilst
sending/receiving.

Any ideas?

Rupert



Quote:
> Adding an Explorer in code will not properly set up things for a COM
> add-in after you start Outlook using automation. The problem is that
> the On_Connection event will have fired already and a properly written
> COM add-in will have detected Explorers.Count = 0 AND Inspectors.Count
> = 0. It will then refuse to init itself. When the Explorer is added in
> code On_Connection does not fire again.

> For an example of how to correctly init and shutdown Outlook COM
> add-ins you should look at ItemsCB on the Resources page at
> www.microeye.com

> The only workaround that would work correctly is to add the Explorer
> in code and then work with the Application.COMAddins collection. You
> have to iterate that collection and toggle the Connect bit for each
> COMAddin member to fire On_Connection again:

> Dim oCOM As Office.COMAddin
> Dim oCOMS As Office.COMAddins

> Set oCOMS = olApp.COMAddins
> For Each oCOM In oCOMS
>     oCOM.Connect = False
>     oCOM.Connect = True
> Next

> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm



> > Thanks Robert,

> > unfortunately, I have not been able to alleviate my problem a lot by
> making
> > the explorer visible. When I close that explorer, Outlook still
> stays
> > invisible in the background - it seems it won't quit after "messing"
> with it
> > through VBA, although I'm careful to close everything and destroy
> all
> > references.

> > So if anyone has insight on the general problem, I would appreciate
> more
> > comments.

> > Rupert



Mon, 27 Dec 2004 17:53:30 GMT  
 Outlook hangs in background - application visibility question
If the problem is repro'd by closing Outlook when doing a send/receive
it sounds like the MAPI spooler is remaining in memory. Can you use
CreateObject in that case? If an instance of Outlook is already
running it would use that and if not it would instantiate a new
instance.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Quote:
> hm. thank you for the background information, but I am not acutally
using
> any COM add-in's. I do use Redemption, though, but I don't think
that is an
> add-in, it's just a dll collection of calls which use the extended
MAPI to
> emulate Outlook functions. Please correct me if I'm wrong, but I
just took a
> look at the COMAddins collection of my automated Outlook. It
contains only
> one item, which is "Microsoft VBA fr Outlook Add-In", even after
using
> Redemption.

> Now, it would help me a lot if I were able to detect an invisible
instance
> of Outlook in the background and shut it down if necessary. At
startup of my
> application, I have it check for a running instance of Outlook with
> GetObject(Class:="Outlook.Application"). If there is a "dead"
Outlook in the
> background, my app will hang on that GetObject call until you throw
out the
> "dead" Outlook process in Task manager.

> And again, this seems to be a general problem with Outlook, as you
can
> easily reproduce it by closing the main application window whilst
> sending/receiving.

> Any ideas?

> Rupert



Mon, 27 Dec 2004 21:55:04 GMT  
 Outlook hangs in background - application visibility question


Quote:
> If the problem is repro'd by closing Outlook when doing a send/receive
> it sounds like the MAPI spooler is remaining in memory. Can you use
> CreateObject in that case? If an instance of Outlook is already
> running it would use that and if not it would instantiate a new
> instance.

Just gave it a try - my app will equally hang both on GetObject and on
CreateObject as soon as there is an invisible instance of Outlook in the
background.

Can you reproduce the problem, anyway? I can create as many "dead" Outlook
instances in the background as I like at anytime: Open Outlook, hit
Send/Receive, close the main window while still sending/receiving. After
sending/receiving has finished, you will have no visible Outlook, but you
can see an OUTLOOK process in Task Manager. Now try to start Outlook again
from the desktop. The cursor will turn to the arrow/hourglass combination
for several seconds, but nothing else happens. Repeat that for 3 times, and
you will have four Outlook processes in Task Manager. If you throw out one
after the other, at the moment where you have killed the second last, the
last one is "unchained" and shows up on the screen.

Rupert

Quote:

> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm



> > hm. thank you for the background information, but I am not acutally
> using
> > any COM add-in's. I do use Redemption, though, but I don't think
> that is an
> > add-in, it's just a dll collection of calls which use the extended
> MAPI to
> > emulate Outlook functions. Please correct me if I'm wrong, but I
> just took a
> > look at the COMAddins collection of my automated Outlook. It
> contains only
> > one item, which is "Microsoft VBA fr Outlook Add-In", even after
> using
> > Redemption.

> > Now, it would help me a lot if I were able to detect an invisible
> instance
> > of Outlook in the background and shut it down if necessary. At
> startup of my
> > application, I have it check for a running instance of Outlook with
> > GetObject(Class:="Outlook.Application"). If there is a "dead"
> Outlook in the
> > background, my app will hang on that GetObject call until you throw
> out the
> > "dead" Outlook process in Task manager.

> > And again, this seems to be a general problem with Outlook, as you
> can
> > easily reproduce it by closing the main application window whilst
> > sending/receiving.

> > Any ideas?

> > Rupert



Tue, 28 Dec 2004 01:45:35 GMT  
 Outlook hangs in background - application visibility question
I can't really test that here since I don't use any dial-up
connections and am connected to my own Exchange server. So items get
sent as soon as I press the Send button. I'd suggest opening an
incident with PSS and seeing if they have any reports of this or
suggested fixes.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Quote:

Newsbeitrag

> > If the problem is repro'd by closing Outlook when doing a
send/receive
> > it sounds like the MAPI spooler is remaining in memory. Can you
use
> > CreateObject in that case? If an instance of Outlook is already
> > running it would use that and if not it would instantiate a new
> > instance.

> Just gave it a try - my app will equally hang both on GetObject and
on
> CreateObject as soon as there is an invisible instance of Outlook in
the
> background.

> Can you reproduce the problem, anyway? I can create as many "dead"
Outlook
> instances in the background as I like at anytime: Open Outlook, hit
> Send/Receive, close the main window while still sending/receiving.
After
> sending/receiving has finished, you will have no visible Outlook,
but you
> can see an OUTLOOK process in Task Manager. Now try to start Outlook
again
> from the desktop. The cursor will turn to the arrow/hourglass
combination
> for several seconds, but nothing else happens. Repeat that for 3
times, and
> you will have four Outlook processes in Task Manager. If you throw
out one
> after the other, at the moment where you have killed the second
last, the
> last one is "unchained" and shows up on the screen.

> Rupert



Tue, 28 Dec 2004 22:31:57 GMT  
 Outlook hangs in background - application visibility question
Rupert,

I was able to reproduce it just they way you described it.  I opened
Outlook, and while it was doing the initial check for messages, I closed
it.  Attempting to open it again (and again and . . .) I ended up with
several instances of Outlook in Task Manager.  On killing the first,
each of the other instances became new Outlook explorers, and they all
combined into one instance.  This was on Windows XP, running Outlook
2000 (no service pack).  I tried it on Office XP, but it appeared to
work correctly.

Sorry I don't have any new ideas for you.  I thought I'd let you know,
though, that I was able to reproduce it.

--
Robert Dunn
Software Developer
Certiport, Inc.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Tue, 28 Dec 2004 22:49:59 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. How to change the visibility property of an outlook control

2. Visibility of applications in VB6

3. Excel OLE Process hangs in background

4. GetDefaultFolder() hangs in background...

5. outlook.application & Active-X Control Question

6. Visibility question (again...)

7. Form (invoked) visibility question.

8. Two question about toolbar and application like as Outlook

9. Outlook Hang ups

10. Outlook hanging

11. After Running Macro, Outlook hangs on exit.

12. Outlook hanging and here is the error message

 

 
Powered by phpBB® Forum Software