![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi
I am using below code to send email from a vb.net app; Public WithEvents OutlookApp As Outlook.Application Dim ns As Outlook.NameSpace OutlookApp = New Outlook.Application ns = OutlookApp.GetNamespace("MAPI") ns.Logon() Dim em As Outlook.MailItem em = CType(OutlookApp.CreateItem(Outlook.OlItemType.olM ailItem), Outlook.MailItem) em.Display(False) Marshal.ReleaseComObject(em) ns.Logoff() Marshal.ReleaseComObject(ns) Marshal.ReleaseComObject(OutlookApp) The code works fine for the first time but running it again produces the following error; System.Reflection.TargetInvocationException was unhandled by user code Message="Exception has been thrown by the target of an invocation." Source="mscorlib" InnerException: System.Runtime.InteropServices.InvalidComObjectExc eption Message="COM object that has been separated from its underlying RCW cannot be used." Source="Interop.Outlook" StackTrace: at Outlook.ApplicationEvents_EventProvider..ctor(Obje ct ) What is the problem and how can I fix it? Thanks Regards |
Ads |
#2
|
|||
|
|||
![]()
Dear John,
Have you tried putting Marshal.ReleaseComObject(em) after ns.Logoff() ?? Hope that helps. CreateWindow http://mymessagetaker.com The while-you-were-out message program you have been looking for! |
#3
|
|||
|
|||
![]()
Hi
Tried ns.Logoff() Marshal.ReleaseComObject(ns) Marshal.ReleaseComObject(em) Marshal.ReleaseComObject(OutlookApp) and ns.Logoff() Marshal.ReleaseComObject(em) Marshal.ReleaseComObject(ns) Marshal.ReleaseComObject(OutlookApp) Still no luck. Thanks Regards wrote in message ... Dear John, Have you tried putting Marshal.ReleaseComObject(em) after ns.Logoff() ?? Hope that helps. CreateWindow http://mymessagetaker.com The while-you-were-out message program you have been looking for! |
#4
|
|||
|
|||
![]()
"John" wrote in message
... I am using below code to send email from a vb.net app; I don't know whether anyone from Microsoft regularly reads the Visual Basic groups but if they do then I am very surprised that they permit one of their own MVPs to engage in such outrageous long term trolling activities in one of their own public newsgroups, such as the activity that the person who purports to be Bill McCarthy has engaged in on the microsoft.public.vb.general.discussion group for many months. If this man belongs to you: https://mvp.support.microsoft.com/pr...9-25680609CCB8 .. . . then perhaps you might like to look at his activity in that group. Here for example is one of his very latest offerings: "Bill McCarthy" wrote in message ... Yeh, still a way to go. I think given the warm reaction today, and given some folks have learning difficulties around here (obviously why they are still *stuck* in VB6 *only*), might just have to ramp things up a notch or two, and make it more toasty ![]() |
#5
|
|||
|
|||
![]()
"John" wrote in message
... Hi Tried ns.Logoff() I don't know whether anyone from Microsoft regularly reads the Visual Basic groups but if they do then I am very surprised that they permit one of their own MVPs to engage in such outrageous long term trolling activities in one of their own public newsgroups, such as the activity that the person who purports to be Bill McCarthy has engaged in on the microsoft.public.vb.general.discussion group for many months. If this man belongs to you: https://mvp.support.microsoft.com/pr...9-25680609CCB8 .. . . then perhaps you might like to look at his activity in that group. Here for example is one of his very latest offerings: "Bill McCarthy" wrote in message ... Yeh, still a way to go. I think given the warm reaction today, and given some folks have learning difficulties around here (obviously why they are still *stuck* in VB6 *only*), might just have to ramp things up a notch or two, and make it more toasty ![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook 2003 primary interop advise | John | Outlook - General Queries | 4 | February 5th 08 09:18 PM |
Interop Assemblies for Outlook 2000 | John | Outlook - General Queries | 1 | February 4th 08 07:09 PM |
How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#) | Godandag | Add-ins for Outlook | 5 | April 5th 07 09:39 AM |
Outlook Interop: Attachments.Add throws Exception | Ferdinand Zaubzer | Outlook and VBA | 1 | June 19th 06 03:10 PM |
Outlook Interop COM Exception When Logged in as Windows Standard User | [email protected] | Add-ins for Outlook | 0 | April 27th 06 12:34 AM |