Connecting Tech Pros Worldwide Help | Site Map

Slow opening of outlook

John
Guest
 
Posts: n/a
#1: Nov 20 '05
Hi

When I open a new outlook email from vb.net, sometimes outlook is very slow
to appear or occasionally outlook freezes completely. I am targeting mixed
office2000/xp environments so I am using the office2000 interop dlls
generated by vs.net by adding office 2000 com reference.

Any one else noticed this problem when targeting office2000/xp mixed
environments? Is there a better, more robust way to do this? Am I better off
using late binding?

Thanks

Regards




Marcel
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Slow opening of outlook


Do you have MS Messenger running ?

"John" <john@nospam.infovis.co.uk> wrote in message
news:#M2n2812DHA.2888@tk2msftngp13.phx.gbl...[color=blue]
> Hi
>
> When I open a new outlook email from vb.net, sometimes outlook is very[/color]
slow[color=blue]
> to appear or occasionally outlook freezes completely. I am targeting mixed
> office2000/xp environments so I am using the office2000 interop dlls
> generated by vs.net by adding office 2000 com reference.
>
> Any one else noticed this problem when targeting office2000/xp mixed
> environments? Is there a better, more robust way to do this? Am I better[/color]
off[color=blue]
> using late binding?
>
> Thanks
>
> Regards
>
>
>
>[/color]


John
Guest
 
Posts: n/a
#3: Nov 20 '05

re: Slow opening of outlook


Nope.

Regards

"Marcel" <sorrytomuch@spam.com> wrote in message
news:e805TB22DHA.540@tk2msftngp13.phx.gbl...[color=blue]
> Do you have MS Messenger running ?
>
> "John" <john@nospam.infovis.co.uk> wrote in message
> news:#M2n2812DHA.2888@tk2msftngp13.phx.gbl...[color=green]
> > Hi
> >
> > When I open a new outlook email from vb.net, sometimes outlook is very[/color]
> slow[color=green]
> > to appear or occasionally outlook freezes completely. I am targeting[/color][/color]
mixed[color=blue][color=green]
> > office2000/xp environments so I am using the office2000 interop dlls
> > generated by vs.net by adding office 2000 com reference.
> >
> > Any one else noticed this problem when targeting office2000/xp mixed
> > environments? Is there a better, more robust way to do this? Am I better[/color]
> off[color=green]
> > using late binding?
> >
> > Thanks
> >
> > Regards
> >
> >
> >
> >[/color]
>
>[/color]


Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#4: Nov 20 '05

re: Slow opening of outlook


John,
Are you starting Outlook fresh or is it already running? When Outlook is
already running does the same thing happen?

Does this happen "right away" or after using Outlook from VB.NET for awhile?

Are you using System.Runtime.InteropServices.Marshal.ReelaseComO bject on
each Outlook object returned, when you are done with that object?

Are you calling Item.Display to show an item or just connecting and
retrieving & updating information? Does this "slowness" happen with specific
Outlook objects & methods?

Do you have other things running on your computer?

Which version of the OS?

Are you using Exchange Server or internet mode?

Are you getting the "security dialog" that states that someone is accessing
your email? And just not seeing it in time?


In case you don't have it, the following site provides a plethora of
articles on using Outlook from .NET:
http://www.microeye.com/resources/res_outlookvsnet.htm

Using Outlook 2003 with VB.NET & the Office 2003 PIA I have not noticed
Outlook being slow to appear.

Unfortunately I don't have a machine with either office 2000 or Office XP.

Hope this helps
Jay

"John" <john@nospam.infovis.co.uk> wrote in message
news:%23M2n2812DHA.2888@tk2msftngp13.phx.gbl...[color=blue]
> Hi
>
> When I open a new outlook email from vb.net, sometimes outlook is very[/color]
slow[color=blue]
> to appear or occasionally outlook freezes completely. I am targeting mixed
> office2000/xp environments so I am using the office2000 interop dlls
> generated by vs.net by adding office 2000 com reference.
>
> Any one else noticed this problem when targeting office2000/xp mixed
> environments? Is there a better, more robust way to do this? Am I better[/color]
off[color=blue]
> using late binding?
>
> Thanks
>
> Regards
>
>
>
>[/color]


John
Guest
 
Posts: n/a
#5: Nov 20 '05

re: Slow opening of outlook


I am using display to allow user to enter the email and then press send
button to send it. I am not using
System.Runtime.InteropServices.Marshal.ReelaseComO bject. Is there an example
I can see on how to use it?

Thanks

Regards

"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:OP7ek922DHA.2700@tk2msftngp13.phx.gbl...[color=blue]
> John,
> Are you starting Outlook fresh or is it already running? When Outlook is
> already running does the same thing happen?
>
> Does this happen "right away" or after using Outlook from VB.NET for[/color]
awhile?[color=blue]
>
> Are you using System.Runtime.InteropServices.Marshal.ReelaseComO bject on
> each Outlook object returned, when you are done with that object?
>
> Are you calling Item.Display to show an item or just connecting and
> retrieving & updating information? Does this "slowness" happen with[/color]
specific[color=blue]
> Outlook objects & methods?
>
> Do you have other things running on your computer?
>
> Which version of the OS?
>
> Are you using Exchange Server or internet mode?
>
> Are you getting the "security dialog" that states that someone is[/color]
accessing[color=blue]
> your email? And just not seeing it in time?
>
>
> In case you don't have it, the following site provides a plethora of
> articles on using Outlook from .NET:
> http://www.microeye.com/resources/res_outlookvsnet.htm
>
> Using Outlook 2003 with VB.NET & the Office 2003 PIA I have not noticed
> Outlook being slow to appear.
>
> Unfortunately I don't have a machine with either office 2000 or Office XP.
>
> Hope this helps
> Jay
>
> "John" <john@nospam.infovis.co.uk> wrote in message
> news:%23M2n2812DHA.2888@tk2msftngp13.phx.gbl...[color=green]
> > Hi
> >
> > When I open a new outlook email from vb.net, sometimes outlook is very[/color]
> slow[color=green]
> > to appear or occasionally outlook freezes completely. I am targeting[/color][/color]
mixed[color=blue][color=green]
> > office2000/xp environments so I am using the office2000 interop dlls
> > generated by vs.net by adding office 2000 com reference.
> >
> > Any one else noticed this problem when targeting office2000/xp mixed
> > environments? Is there a better, more robust way to do this? Am I better[/color]
> off[color=green]
> > using late binding?
> >
> > Thanks
> >
> > Regards
> >
> >
> >
> >[/color]
>
>[/color]


Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#6: Nov 20 '05

re: Slow opening of outlook


John,
Did you try searching MSDN for ReleaseComObject?

The first link returned looks like a promising example:

http://msdn.microsoft.com/library/de...omateVBNet.asp

The second link is the documentation for the function:

http://msdn.microsoft.com/library/de...bjecttopic.asp

Hope this helps
Jay


"John" <john@nospam.infovis.co.uk> wrote in message
news:OtDxYyn6DHA.3704@tk2msftngp13.phx.gbl...[color=blue]
> I am using display to allow user to enter the email and then press send
> button to send it. I am not using
> System.Runtime.InteropServices.Marshal.ReelaseComO bject. Is there an[/color]
example[color=blue]
> I can see on how to use it?
>
> Thanks
>
> Regards
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
> news:OP7ek922DHA.2700@tk2msftngp13.phx.gbl...[color=green]
> > John,
> > Are you starting Outlook fresh or is it already running? When Outlook is
> > already running does the same thing happen?
> >
> > Does this happen "right away" or after using Outlook from VB.NET for[/color]
> awhile?[color=green]
> >
> > Are you using System.Runtime.InteropServices.Marshal.ReelaseComO bject on
> > each Outlook object returned, when you are done with that object?
> >
> > Are you calling Item.Display to show an item or just connecting and
> > retrieving & updating information? Does this "slowness" happen with[/color]
> specific[color=green]
> > Outlook objects & methods?
> >
> > Do you have other things running on your computer?
> >
> > Which version of the OS?
> >
> > Are you using Exchange Server or internet mode?
> >
> > Are you getting the "security dialog" that states that someone is[/color]
> accessing[color=green]
> > your email? And just not seeing it in time?
> >
> >
> > In case you don't have it, the following site provides a plethora of
> > articles on using Outlook from .NET:
> > http://www.microeye.com/resources/res_outlookvsnet.htm
> >
> > Using Outlook 2003 with VB.NET & the Office 2003 PIA I have not noticed
> > Outlook being slow to appear.
> >
> > Unfortunately I don't have a machine with either office 2000 or Office[/color][/color]
XP.[color=blue][color=green]
> >
> > Hope this helps
> > Jay
> >
> > "John" <john@nospam.infovis.co.uk> wrote in message
> > news:%23M2n2812DHA.2888@tk2msftngp13.phx.gbl...[color=darkred]
> > > Hi
> > >
> > > When I open a new outlook email from vb.net, sometimes outlook is[/color][/color][/color]
very[color=blue][color=green]
> > slow[color=darkred]
> > > to appear or occasionally outlook freezes completely. I am targeting[/color][/color]
> mixed[color=green][color=darkred]
> > > office2000/xp environments so I am using the office2000 interop dlls
> > > generated by vs.net by adding office 2000 com reference.
> > >
> > > Any one else noticed this problem when targeting office2000/xp mixed
> > > environments? Is there a better, more robust way to do this? Am I[/color][/color][/color]
better[color=blue][color=green]
> > off[color=darkred]
> > > using late binding?
> > >
> > > Thanks
> > >
> > > Regards
> > >
> > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


John
Guest
 
Posts: n/a
#7: Nov 20 '05

re: Slow opening of outlook


Hi

Not sure how to relate the access example with outlook. Tried to mimic it
but no luck and same error. Isn't there an outlook example around, creating
a new email then display and then cleanup?

Regards

"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:uOP7SFo6DHA.2168@TK2MSFTNGP12.phx.gbl...[color=blue]
> John,
> Did you try searching MSDN for ReleaseComObject?
>
> The first link returned looks like a promising example:
>
>[/color]
http://msdn.microsoft.com/library/de...omateVBNet.asp[color=blue]
>
> The second link is the documentation for the function:
>
>[/color]
http://msdn.microsoft.com/library/de...bjecttopic.asp[color=blue]
>
> Hope this helps
> Jay
>
>
> "John" <john@nospam.infovis.co.uk> wrote in message
> news:OtDxYyn6DHA.3704@tk2msftngp13.phx.gbl...[color=green]
> > I am using display to allow user to enter the email and then press send
> > button to send it. I am not using
> > System.Runtime.InteropServices.Marshal.ReelaseComO bject. Is there an[/color]
> example[color=green]
> > I can see on how to use it?
> >
> > Thanks
> >
> > Regards
> >
> > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color][/color]
message[color=blue][color=green]
> > news:OP7ek922DHA.2700@tk2msftngp13.phx.gbl...[color=darkred]
> > > John,
> > > Are you starting Outlook fresh or is it already running? When Outlook[/color][/color][/color]
is[color=blue][color=green][color=darkred]
> > > already running does the same thing happen?
> > >
> > > Does this happen "right away" or after using Outlook from VB.NET for[/color]
> > awhile?[color=darkred]
> > >
> > > Are you using System.Runtime.InteropServices.Marshal.ReelaseComO bject[/color][/color][/color]
on[color=blue][color=green][color=darkred]
> > > each Outlook object returned, when you are done with that object?
> > >
> > > Are you calling Item.Display to show an item or just connecting and
> > > retrieving & updating information? Does this "slowness" happen with[/color]
> > specific[color=darkred]
> > > Outlook objects & methods?
> > >
> > > Do you have other things running on your computer?
> > >
> > > Which version of the OS?
> > >
> > > Are you using Exchange Server or internet mode?
> > >
> > > Are you getting the "security dialog" that states that someone is[/color]
> > accessing[color=darkred]
> > > your email? And just not seeing it in time?
> > >
> > >
> > > In case you don't have it, the following site provides a plethora of
> > > articles on using Outlook from .NET:
> > > http://www.microeye.com/resources/res_outlookvsnet.htm
> > >
> > > Using Outlook 2003 with VB.NET & the Office 2003 PIA I have not[/color][/color][/color]
noticed[color=blue][color=green][color=darkred]
> > > Outlook being slow to appear.
> > >
> > > Unfortunately I don't have a machine with either office 2000 or Office[/color][/color]
> XP.[color=green][color=darkred]
> > >
> > > Hope this helps
> > > Jay
> > >
> > > "John" <john@nospam.infovis.co.uk> wrote in message
> > > news:%23M2n2812DHA.2888@tk2msftngp13.phx.gbl...
> > > > Hi
> > > >
> > > > When I open a new outlook email from vb.net, sometimes outlook is[/color][/color]
> very[color=green][color=darkred]
> > > slow
> > > > to appear or occasionally outlook freezes completely. I am targeting[/color]
> > mixed[color=darkred]
> > > > office2000/xp environments so I am using the office2000 interop dlls
> > > > generated by vs.net by adding office 2000 com reference.
> > > >
> > > > Any one else noticed this problem when targeting office2000/xp mixed
> > > > environments? Is there a better, more robust way to do this? Am I[/color][/color]
> better[color=green][color=darkred]
> > > off
> > > > using late binding?
> > > >
> > > > Thanks
> > > >
> > > > Regards
> > > >
> > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#8: Nov 20 '05

re: Slow opening of outlook


John,
How does that saying go: Give a man a fish he eats for a day, teach a man to
fix he eats for live? :-)

The Access example should show you enough of the Concept of working with
Office Automation & ReleaseComObject when combined with the Outlook VBA Help
you should be able to create a working example! As I find VB6 & VBA examples
come are translated almost 1 for 1, the few exceptions to the rule I find
are easy to remember.
[color=blue]
> but no luck and same error. Isn't there an outlook example around,[/color]
creating[color=blue]
> a new email then display and then cleanup?[/color]
Unfortunately I am not setup to test Outlook 2000 automation with .NET.
However! others have used Outlook 2000 from VB.NET with success, have you
reviewed the info at:

http://www.microeye.com/resources/res_outlookvsnet.htm

There is at least one article that specifically deals specifically with
Outlook 2000!

Here is an example of "creating a new email, then display, and then
cleanup":

Imports System.Runtime.InteropServices
Dim app As New Outlook.Application
Dim ns As Outlook.NameSpace
ns = app.GetNamespace("MAPI")
ns.Logon()
Dim mailItem As Outlook.MailItem
mailItem = DirectCast(app.CreateItem(Outlook.OlItemType.olMai lItem),
Outlook.MailItem)
mailItem.Display(False)

Marshal.ReleaseComObject(mailItem)
ns.Logoff()
Marshal.ReleaseComObject(ns)
Marshal.ReleaseComObject(app)
Return

I am checking with my fellow Outlook MVPs on why mailItem.Display(True)
leaves the window on the screen.

Hope this helps
Jay


"John" <john@nospam.infovis.co.uk> wrote in message
news:%239lwmVs6DHA.3860@tk2msftngp13.phx.gbl...[color=blue]
> Hi
>
> Not sure how to relate the access example with outlook. Tried to mimic it
> but no luck and same error. Isn't there an outlook example around,[/color]
creating[color=blue]
> a new email then display and then cleanup?
>
> Regards
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
> news:uOP7SFo6DHA.2168@TK2MSFTNGP12.phx.gbl...[color=green]
> > John,
> > Did you try searching MSDN for ReleaseComObject?
> >
> > The first link returned looks like a promising example:
> >
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...omateVBNet.asp[color=blue][color=green]
> >
> > The second link is the documentation for the function:
> >
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...bjecttopic.asp[color=blue][color=green]
> >
> > Hope this helps
> > Jay
> >
> >
> > "John" <john@nospam.infovis.co.uk> wrote in message
> > news:OtDxYyn6DHA.3704@tk2msftngp13.phx.gbl...[color=darkred]
> > > I am using display to allow user to enter the email and then press[/color][/color][/color]
send[color=blue][color=green][color=darkred]
> > > button to send it. I am not using
> > > System.Runtime.InteropServices.Marshal.ReelaseComO bject. Is there an[/color]
> > example[color=darkred]
> > > I can see on how to use it?
> > >
> > > Thanks
> > >
> > > Regards
> > >
> > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color][/color]
> message[color=green][color=darkred]
> > > news:OP7ek922DHA.2700@tk2msftngp13.phx.gbl...
> > > > John,
> > > > Are you starting Outlook fresh or is it already running? When[/color][/color][/color]
Outlook[color=blue]
> is[color=green][color=darkred]
> > > > already running does the same thing happen?
> > > >
> > > > Does this happen "right away" or after using Outlook from VB.NET for
> > > awhile?
> > > >
> > > > Are you using[/color][/color][/color]
System.Runtime.InteropServices.Marshal.ReelaseComO bject[color=blue]
> on[color=green][color=darkred]
> > > > each Outlook object returned, when you are done with that object?
> > > >
> > > > Are you calling Item.Display to show an item or just connecting and
> > > > retrieving & updating information? Does this "slowness" happen with
> > > specific
> > > > Outlook objects & methods?
> > > >
> > > > Do you have other things running on your computer?
> > > >
> > > > Which version of the OS?
> > > >
> > > > Are you using Exchange Server or internet mode?
> > > >
> > > > Are you getting the "security dialog" that states that someone is
> > > accessing
> > > > your email? And just not seeing it in time?
> > > >
> > > >
> > > > In case you don't have it, the following site provides a plethora of
> > > > articles on using Outlook from .NET:
> > > > http://www.microeye.com/resources/res_outlookvsnet.htm
> > > >
> > > > Using Outlook 2003 with VB.NET & the Office 2003 PIA I have not[/color][/color]
> noticed[color=green][color=darkred]
> > > > Outlook being slow to appear.
> > > >
> > > > Unfortunately I don't have a machine with either office 2000 or[/color][/color][/color]
Office[color=blue][color=green]
> > XP.[color=darkred]
> > > >
> > > > Hope this helps
> > > > Jay
> > > >
> > > > "John" <john@nospam.infovis.co.uk> wrote in message
> > > > news:%23M2n2812DHA.2888@tk2msftngp13.phx.gbl...
> > > > > Hi
> > > > >
> > > > > When I open a new outlook email from vb.net, sometimes outlook is[/color]
> > very[color=darkred]
> > > > slow
> > > > > to appear or occasionally outlook freezes completely. I am[/color][/color][/color]
targeting[color=blue][color=green][color=darkred]
> > > mixed
> > > > > office2000/xp environments so I am using the office2000 interop[/color][/color][/color]
dlls[color=blue][color=green][color=darkred]
> > > > > generated by vs.net by adding office 2000 com reference.
> > > > >
> > > > > Any one else noticed this problem when targeting office2000/xp[/color][/color][/color]
mixed[color=blue][color=green][color=darkred]
> > > > > environments? Is there a better, more robust way to do this? Am I[/color]
> > better[color=darkred]
> > > > off
> > > > > using late binding?
> > > > >
> > > > > Thanks
> > > > >
> > > > > Regards
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#9: Nov 20 '05

re: Slow opening of outlook


John,
Are you using Word as the Editor in Outlook?

There seems to be a problem closing Word when used as the Editor in Outlook,
try the following code to close Word.

Something like:
Dim app As New Outlook.Application
Dim mailItem As Outlook.MailItem
mailItem = DirectCast(app.CreateItem(Outlook.OlItemType.olMai lItem),
Outlook.MailItem)
Dim objInsp As Outlook.Inspector
objInsp = mailItem.GetInspector()

mailItem.Display(True)

Marshal.ReleaseComObject(objInsp)

Marshal.ReleaseComObject(mailItem)
Marshal.ReleaseComObject(app)

Note, the dialog is not displayed modally, but its left open for you to fill
out & send...

Hope this helps
Jay

"John" <john@nospam.infovis.co.uk> wrote in message
news:%239lwmVs6DHA.3860@tk2msftngp13.phx.gbl...[color=blue]
> Hi
>
> Not sure how to relate the access example with outlook. Tried to mimic it
> but no luck and same error. Isn't there an outlook example around,[/color]
creating[color=blue]
> a new email then display and then cleanup?
>
> Regards
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
> news:uOP7SFo6DHA.2168@TK2MSFTNGP12.phx.gbl...[color=green]
> > John,
> > Did you try searching MSDN for ReleaseComObject?
> >
> > The first link returned looks like a promising example:
> >
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...omateVBNet.asp[color=blue][color=green]
> >
> > The second link is the documentation for the function:
> >
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...bjecttopic.asp[color=blue][color=green]
> >
> > Hope this helps
> > Jay
> >
> >
> > "John" <john@nospam.infovis.co.uk> wrote in message
> > news:OtDxYyn6DHA.3704@tk2msftngp13.phx.gbl...[color=darkred]
> > > I am using display to allow user to enter the email and then press[/color][/color][/color]
send[color=blue][color=green][color=darkred]
> > > button to send it. I am not using
> > > System.Runtime.InteropServices.Marshal.ReelaseComO bject. Is there an[/color]
> > example[color=darkred]
> > > I can see on how to use it?
> > >
> > > Thanks
> > >
> > > Regards
> > >
> > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color][/color]
> message[color=green][color=darkred]
> > > news:OP7ek922DHA.2700@tk2msftngp13.phx.gbl...
> > > > John,
> > > > Are you starting Outlook fresh or is it already running? When[/color][/color][/color]
Outlook[color=blue]
> is[color=green][color=darkred]
> > > > already running does the same thing happen?
> > > >
> > > > Does this happen "right away" or after using Outlook from VB.NET for
> > > awhile?
> > > >
> > > > Are you using[/color][/color][/color]
System.Runtime.InteropServices.Marshal.ReelaseComO bject[color=blue]
> on[color=green][color=darkred]
> > > > each Outlook object returned, when you are done with that object?
> > > >
> > > > Are you calling Item.Display to show an item or just connecting and
> > > > retrieving & updating information? Does this "slowness" happen with
> > > specific
> > > > Outlook objects & methods?
> > > >
> > > > Do you have other things running on your computer?
> > > >
> > > > Which version of the OS?
> > > >
> > > > Are you using Exchange Server or internet mode?
> > > >
> > > > Are you getting the "security dialog" that states that someone is
> > > accessing
> > > > your email? And just not seeing it in time?
> > > >
> > > >
> > > > In case you don't have it, the following site provides a plethora of
> > > > articles on using Outlook from .NET:
> > > > http://www.microeye.com/resources/res_outlookvsnet.htm
> > > >
> > > > Using Outlook 2003 with VB.NET & the Office 2003 PIA I have not[/color][/color]
> noticed[color=green][color=darkred]
> > > > Outlook being slow to appear.
> > > >
> > > > Unfortunately I don't have a machine with either office 2000 or[/color][/color][/color]
Office[color=blue][color=green]
> > XP.[color=darkred]
> > > >
> > > > Hope this helps
> > > > Jay
> > > >
> > > > "John" <john@nospam.infovis.co.uk> wrote in message
> > > > news:%23M2n2812DHA.2888@tk2msftngp13.phx.gbl...
> > > > > Hi
> > > > >
> > > > > When I open a new outlook email from vb.net, sometimes outlook is[/color]
> > very[color=darkred]
> > > > slow
> > > > > to appear or occasionally outlook freezes completely. I am[/color][/color][/color]
targeting[color=blue][color=green][color=darkred]
> > > mixed
> > > > > office2000/xp environments so I am using the office2000 interop[/color][/color][/color]
dlls[color=blue][color=green][color=darkred]
> > > > > generated by vs.net by adding office 2000 com reference.
> > > > >
> > > > > Any one else noticed this problem when targeting office2000/xp[/color][/color][/color]
mixed[color=blue][color=green][color=darkred]
> > > > > environments? Is there a better, more robust way to do this? Am I[/color]
> > better[color=darkred]
> > > > off
> > > > > using late binding?
> > > > >
> > > > > Thanks
> > > > >
> > > > > Regards
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


John
Guest
 
Posts: n/a
#10: Nov 20 '05

re: Slow opening of outlook



Thanks for that. It works fine the first time but calling the code second
time gives the following error;

Unhandled Exception: System.Reflection.TargetInvocationException: Exception
has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.InvalidComObjectExc eption: COM object that
has been separated from its underlying RCW can not be used.
at Outlook.ApplicationEvents_EventProvider..ctor(Obje ct )

I am using the below code and the error comes on the 'OutlookApp = New
Outlook.Application' line. Any ideas what I am missing?

Thanks

Regards

= Code below =======================

Imports System.Runtime.InteropServices

Public Class clsOfficeWrapper
Private WithEvents OutlookApp As Outlook.Application
Private WithEvents em As Outlook.MailItem

Public Sub NewEmail(ByVal EmailTemplate As String, ByVal SendTo As String)
Dim ns As Outlook.NameSpace

OutlookApp = New Outlook.Application ' <=== This lines give the
exception second time round
ns = OutlookApp.GetNamespace("MAPI")
ns.Logon()

em = DirectCast(OutlookApp.CreateItemFromTemplate(Email Template),
Outlook.MailItem)
.To = SendTo
.Display(False)

Marshal.ReleaseComObject(em)
ns.Logoff()
Marshal.ReleaseComObject(ns)
Marshal.ReleaseComObject(OutlookApp)
End Sub
....

End Class

"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:%23HSCBpy6DHA.3860@tk2msftngp13.phx.gbl...[color=blue]
> John,
> How does that saying go: Give a man a fish he eats for a day, teach a man[/color]
to[color=blue]
> fix he eats for live? :-)
>
> The Access example should show you enough of the Concept of working with
> Office Automation & ReleaseComObject when combined with the Outlook VBA[/color]
Help[color=blue]
> you should be able to create a working example! As I find VB6 & VBA[/color]
examples[color=blue]
> come are translated almost 1 for 1, the few exceptions to the rule I find
> are easy to remember.
>[color=green]
> > but no luck and same error. Isn't there an outlook example around,[/color]
> creating[color=green]
> > a new email then display and then cleanup?[/color]
> Unfortunately I am not setup to test Outlook 2000 automation with .NET.
> However! others have used Outlook 2000 from VB.NET with success, have you
> reviewed the info at:
>
> http://www.microeye.com/resources/res_outlookvsnet.htm
>
> There is at least one article that specifically deals specifically with
> Outlook 2000!
>
> Here is an example of "creating a new email, then display, and then
> cleanup":
>
> Imports System.Runtime.InteropServices
> Dim app As New Outlook.Application
> Dim ns As Outlook.NameSpace
> ns = app.GetNamespace("MAPI")
> ns.Logon()
> Dim mailItem As Outlook.MailItem
> mailItem =[/color]
DirectCast(app.CreateItem(Outlook.OlItemType.olMai lItem),[color=blue]
> Outlook.MailItem)
> mailItem.Display(False)
>
> Marshal.ReleaseComObject(mailItem)
> ns.Logoff()
> Marshal.ReleaseComObject(ns)
> Marshal.ReleaseComObject(app)
> Return
>
> I am checking with my fellow Outlook MVPs on why mailItem.Display(True)
> leaves the window on the screen.
>
> Hope this helps
> Jay
>
>
> "John" <john@nospam.infovis.co.uk> wrote in message
> news:%239lwmVs6DHA.3860@tk2msftngp13.phx.gbl...[color=green]
> > Hi
> >
> > Not sure how to relate the access example with outlook. Tried to mimic[/color][/color]
it[color=blue][color=green]
> > but no luck and same error. Isn't there an outlook example around,[/color]
> creating[color=green]
> > a new email then display and then cleanup?
> >
> > Regards
> >
> > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color][/color]
message[color=blue][color=green]
> > news:uOP7SFo6DHA.2168@TK2MSFTNGP12.phx.gbl...[color=darkred]
> > > John,
> > > Did you try searching MSDN for ReleaseComObject?
> > >
> > > The first link returned looks like a promising example:
> > >
> > >[/color]
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...omateVBNet.asp[color=blue][color=green][color=darkred]
> > >
> > > The second link is the documentation for the function:
> > >
> > >[/color]
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...bjecttopic.asp[color=blue][color=green][color=darkred]
> > >
> > > Hope this helps
> > > Jay
> > >
> > >
> > > "John" <john@nospam.infovis.co.uk> wrote in message
> > > news:OtDxYyn6DHA.3704@tk2msftngp13.phx.gbl...
> > > > I am using display to allow user to enter the email and then press[/color][/color]
> send[color=green][color=darkred]
> > > > button to send it. I am not using
> > > > System.Runtime.InteropServices.Marshal.ReelaseComO bject. Is there an
> > > example
> > > > I can see on how to use it?
> > > >
> > > > Thanks
> > > >
> > > > Regards
> > > >
> > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color]
> > message[color=darkred]
> > > > news:OP7ek922DHA.2700@tk2msftngp13.phx.gbl...
> > > > > John,
> > > > > Are you starting Outlook fresh or is it already running? When[/color][/color]
> Outlook[color=green]
> > is[color=darkred]
> > > > > already running does the same thing happen?
> > > > >
> > > > > Does this happen "right away" or after using Outlook from VB.NET[/color][/color][/color]
for[color=blue][color=green][color=darkred]
> > > > awhile?
> > > > >
> > > > > Are you using[/color][/color]
> System.Runtime.InteropServices.Marshal.ReelaseComO bject[color=green]
> > on[color=darkred]
> > > > > each Outlook object returned, when you are done with that object?
> > > > >
> > > > > Are you calling Item.Display to show an item or just connecting[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > > > retrieving & updating information? Does this "slowness" happen[/color][/color][/color]
with[color=blue][color=green][color=darkred]
> > > > specific
> > > > > Outlook objects & methods?
> > > > >
> > > > > Do you have other things running on your computer?
> > > > >
> > > > > Which version of the OS?
> > > > >
> > > > > Are you using Exchange Server or internet mode?
> > > > >
> > > > > Are you getting the "security dialog" that states that someone is
> > > > accessing
> > > > > your email? And just not seeing it in time?
> > > > >
> > > > >
> > > > > In case you don't have it, the following site provides a plethora[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > > > articles on using Outlook from .NET:
> > > > > http://www.microeye.com/resources/res_outlookvsnet.htm
> > > > >
> > > > > Using Outlook 2003 with VB.NET & the Office 2003 PIA I have not[/color]
> > noticed[color=darkred]
> > > > > Outlook being slow to appear.
> > > > >
> > > > > Unfortunately I don't have a machine with either office 2000 or[/color][/color]
> Office[color=green][color=darkred]
> > > XP.
> > > > >
> > > > > Hope this helps
> > > > > Jay
> > > > >
> > > > > "John" <john@nospam.infovis.co.uk> wrote in message
> > > > > news:%23M2n2812DHA.2888@tk2msftngp13.phx.gbl...
> > > > > > Hi
> > > > > >
> > > > > > When I open a new outlook email from vb.net, sometimes outlook[/color][/color][/color]
is[color=blue][color=green][color=darkred]
> > > very
> > > > > slow
> > > > > > to appear or occasionally outlook freezes completely. I am[/color][/color]
> targeting[color=green][color=darkred]
> > > > mixed
> > > > > > office2000/xp environments so I am using the office2000 interop[/color][/color]
> dlls[color=green][color=darkred]
> > > > > > generated by vs.net by adding office 2000 com reference.
> > > > > >
> > > > > > Any one else noticed this problem when targeting office2000/xp[/color][/color]
> mixed[color=green][color=darkred]
> > > > > > environments? Is there a better, more robust way to do this? Am[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > better
> > > > > off
> > > > > > using late binding?
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > Regards
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


John
Guest
 
Posts: n/a
#11: Nov 20 '05

re: Slow opening of outlook


I am not using word as editor.

Thanks

Regards


"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:e9jnpq56DHA.2540@TK2MSFTNGP11.phx.gbl...[color=blue]
> John,
> Are you using Word as the Editor in Outlook?
>
> There seems to be a problem closing Word when used as the Editor in[/color]
Outlook,[color=blue]
> try the following code to close Word.
>
> Something like:
> Dim app As New Outlook.Application
> Dim mailItem As Outlook.MailItem
> mailItem =[/color]
DirectCast(app.CreateItem(Outlook.OlItemType.olMai lItem),[color=blue]
> Outlook.MailItem)
> Dim objInsp As Outlook.Inspector
> objInsp = mailItem.GetInspector()
>
> mailItem.Display(True)
>
> Marshal.ReleaseComObject(objInsp)
>
> Marshal.ReleaseComObject(mailItem)
> Marshal.ReleaseComObject(app)
>
> Note, the dialog is not displayed modally, but its left open for you to[/color]
fill[color=blue]
> out & send...
>
> Hope this helps
> Jay
>
> "John" <john@nospam.infovis.co.uk> wrote in message
> news:%239lwmVs6DHA.3860@tk2msftngp13.phx.gbl...[color=green]
> > Hi
> >
> > Not sure how to relate the access example with outlook. Tried to mimic[/color][/color]
it[color=blue][color=green]
> > but no luck and same error. Isn't there an outlook example around,[/color]
> creating[color=green]
> > a new email then display and then cleanup?
> >
> > Regards
> >
> > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color][/color]
message[color=blue][color=green]
> > news:uOP7SFo6DHA.2168@TK2MSFTNGP12.phx.gbl...[color=darkred]
> > > John,
> > > Did you try searching MSDN for ReleaseComObject?
> > >
> > > The first link returned looks like a promising example:
> > >
> > >[/color]
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...omateVBNet.asp[color=blue][color=green][color=darkred]
> > >
> > > The second link is the documentation for the function:
> > >
> > >[/color]
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...bjecttopic.asp[color=blue][color=green][color=darkred]
> > >
> > > Hope this helps
> > > Jay
> > >
> > >
> > > "John" <john@nospam.infovis.co.uk> wrote in message
> > > news:OtDxYyn6DHA.3704@tk2msftngp13.phx.gbl...
> > > > I am using display to allow user to enter the email and then press[/color][/color]
> send[color=green][color=darkred]
> > > > button to send it. I am not using
> > > > System.Runtime.InteropServices.Marshal.ReelaseComO bject. Is there an
> > > example
> > > > I can see on how to use it?
> > > >
> > > > Thanks
> > > >
> > > > Regards
> > > >
> > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color]
> > message[color=darkred]
> > > > news:OP7ek922DHA.2700@tk2msftngp13.phx.gbl...
> > > > > John,
> > > > > Are you starting Outlook fresh or is it already running? When[/color][/color]
> Outlook[color=green]
> > is[color=darkred]
> > > > > already running does the same thing happen?
> > > > >
> > > > > Does this happen "right away" or after using Outlook from VB.NET[/color][/color][/color]
for[color=blue][color=green][color=darkred]
> > > > awhile?
> > > > >
> > > > > Are you using[/color][/color]
> System.Runtime.InteropServices.Marshal.ReelaseComO bject[color=green]
> > on[color=darkred]
> > > > > each Outlook object returned, when you are done with that object?
> > > > >
> > > > > Are you calling Item.Display to show an item or just connecting[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > > > retrieving & updating information? Does this "slowness" happen[/color][/color][/color]
with[color=blue][color=green][color=darkred]
> > > > specific
> > > > > Outlook objects & methods?
> > > > >
> > > > > Do you have other things running on your computer?
> > > > >
> > > > > Which version of the OS?
> > > > >
> > > > > Are you using Exchange Server or internet mode?
> > > > >
> > > > > Are you getting the "security dialog" that states that someone is
> > > > accessing
> > > > > your email? And just not seeing it in time?
> > > > >
> > > > >
> > > > > In case you don't have it, the following site provides a plethora[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > > > articles on using Outlook from .NET:
> > > > > http://www.microeye.com/resources/res_outlookvsnet.htm
> > > > >
> > > > > Using Outlook 2003 with VB.NET & the Office 2003 PIA I have not[/color]
> > noticed[color=darkred]
> > > > > Outlook being slow to appear.
> > > > >
> > > > > Unfortunately I don't have a machine with either office 2000 or[/color][/color]
> Office[color=green][color=darkred]
> > > XP.
> > > > >
> > > > > Hope this helps
> > > > > Jay
> > > > >
> > > > > "John" <john@nospam.infovis.co.uk> wrote in message
> > > > > news:%23M2n2812DHA.2888@tk2msftngp13.phx.gbl...
> > > > > > Hi
> > > > > >
> > > > > > When I open a new outlook email from vb.net, sometimes outlook[/color][/color][/color]
is[color=blue][color=green][color=darkred]
> > > very
> > > > > slow
> > > > > > to appear or occasionally outlook freezes completely. I am[/color][/color]
> targeting[color=green][color=darkred]
> > > > mixed
> > > > > > office2000/xp environments so I am using the office2000 interop[/color][/color]
> dlls[color=green][color=darkred]
> > > > > > generated by vs.net by adding office 2000 com reference.
> > > > > >
> > > > > > Any one else noticed this problem when targeting office2000/xp[/color][/color]
> mixed[color=green][color=darkred]
> > > > > > environments? Is there a better, more robust way to do this? Am[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > better
> > > > > off
> > > > > > using late binding?
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > Regards
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread