Two Very Puzzling Outlook 2003 Issues

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

I'm using VB.NET to read emails in Outlook 2003.
Here are my 2 puzzling situations:
1) I "Dim oApp As New Outlook.Application" and Dim whatever else I need in
a Sub.
Before exiting the Sub I "oApp.Quit" and "oApp = Nothing".
However, in Task Manager I can still see Outlook running.
How to I get Outlook to close down completely?

2) The Inbox that I check has emails coming in and out. However, when I
call the
Sub that reads the emails it only finds the ones at a certain time and
will not
refresh until I restart the program. Even though the Sub Dims the
Outlook
application and sets it to Nothing before exiting, when I call that Sub
again it will
only return the same emails as the previous loop, even though there may
actually
be more emails. Only on restarting the program will I then get the new
emails.

I looked for a Refresh method for the Outlook application (also on
Outlook
Folders) but could not find anything.

Any suggestions will be greatly appreciated!

Rita
 
If you have the folder's Items collection it will return all the items in
that folder. You don't need to refresh but you might need to release and
re-instantiate your Items collection. Also, the same factors that are
keeping Outlook open are probably keeping a handle to the previous Items
collection.

..NET code will keep object handles even if you set them to Nothing until the
garbage collector runs. You must explicitly call the garbage collector to
permit Outlook to close. You will also need to call Marshal.ReleaseComObject
for your objects. See
http://www.outlookcode.com/threads.aspx?forumid=5&messageid=9226 for an
example.
 
Thanks for your response Ken. It looks mighty complicated to me just to
release some memory (where a set to Nothing in VB 6 did the same thing) but
I'll give it a shot!
 
..NET code for Outlook is even more cranky and complex than COM code is. I
stick with VB 6 for my Outlook development.
 
Back
Top