473,395 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Closing outlook

Hi

I am using outlook to display and send new mail message from within vb.net.
What is the correct way to close outlook after I am done? If I use
outlookapp.quit then any running outlook copy also closes which is
inconvenient for user. If I use outlookapp = nothing then strange things
happen afterwards, such as the mail message not being sent when pressing
Send button. Is there a way to close only the instance of outlook that was
opened from within vb.net and not the main outlook app which was run
separately?

Thanks

Regards
Nov 20 '05 #1
2 5018
Hi John
Try
System.Runtime.InteropServices.Marshal.ReleaseComO bject
(outlookapp)

Kind Regards
Jorge
-----Original Message-----
Hi

I am using outlook to display and send new mail message from within vb.net.What is the correct way to close outlook after I am done? If I useoutlookapp.quit then any running outlook copy also closes which isinconvenient for user. If I use outlookapp = nothing then strange thingshappen afterwards, such as the mail message not being sent when pressingSend button. Is there a way to close only the instance of outlook that wasopened from within vb.net and not the main outlook app which was runseparately?

Thanks

Regards
.

Nov 20 '05 #2
Tried that but when I try to send a second mail I get the 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.

Here is the jist of my code;

Private WithEvents OutlookApp As Outlook.Application
Private WithEvents em As Outlook.MailItem

OutlookApp = New Outlook.Application '<=== I am getting the above error
here.
em = OutlookApp.CreateItemFromTemplate(EmailTemplate)

em.To = "me@mydomain.com"
em.Display(True)

' em = Nothing

' OutlookApp = Nothing ' This caused straneg effects
' OutlookApp.Quit() ' This caused outlook app to close too
System.Runtime.InteropServices.Marshal.ReleaseComO bject(OutlookApp) ' This
is what I am trying now
"Jorge" <an*******@discussions.microsoft.com> wrote in message
news:98****************************@phx.gbl...
Hi John
Try
System.Runtime.InteropServices.Marshal.ReleaseComO bject
(outlookapp)

Kind Regards
Jorge
-----Original Message-----
Hi

I am using outlook to display and send new mail message

from within vb.net.
What is the correct way to close outlook after I am

done? If I use
outlookapp.quit then any running outlook copy also

closes which is
inconvenient for user. If I use outlookapp = nothing

then strange things
happen afterwards, such as the mail message not being

sent when pressing
Send button. Is there a way to close only the instance

of outlook that was
opened from within vb.net and not the main outlook app

which was run
separately?

Thanks

Regards
.

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fritz Switzer | last post by:
Can anyone provide a small snippet in C# that pulls out the Contacts in Outlook XP. I've seen a couple of examples in C++ and VB in previous newsgroup posts, but either the originals didn't work...
10
by: John | last post by:
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...
9
by: George McCullen | last post by:
I have an Outlook 2003 using Exchange Server 2003 Public Contacts Folder containing 20,000 Contacts. I am writing a VB .Net 2003 program that loops through all the contacts in a "for each oCt in...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
26
by: Tom Becker | last post by:
Is there a way, from Access, to programmatically click the Send and Receive button in Outlook?
1
by: Lars54 | last post by:
Happy New Year I'm having an issue with my Outlook 2003, a VB 6 program written some years ago seems causing an issue after closing Outlook. I'm logging time data into Appointment folder so...
5
by: jacc14 | last post by:
Please can anyone help. I am trying to add a button to a form which will pick up an email address, launch outlook, place the address in "Sendto" field and then let me manually type a letter. ...
1
by: 1andy1 | last post by:
Hello, I have a following problem. Development environment Windows XP, VS 2008, Outlook 2003. Deployment environment Small bussiness server, Outlook 2000. I have created a small VB .Net program...
0
by: Aaron Lawrence | last post by:
I send emails many times a day. All of the formatting is identical every time, there are just some values that change. Currently I have VB code that, when launched, opens a form where I enter the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.