Opening email from a share breaks add-in

Status
Not open for further replies.
Q

QW5kcmV3

Hello Folks,

I have a 2007 Outlook add-in developed in VB.Net which throws the following

error, when an email is attempted to be opened from a share: "Cannot open

file: "file name and path here." The file may not exist, you may not have

permission to open it, or it may be open in another program. Right-click the

folder that contains the file, and then click Properties to check your

permissions for the folder."

The weird thing is sometimes it opens, but most times it doesn't and throws

that error. The code is written to handle the "NewInspector" event which

should run when the email is opened. In the times, the error is throw, the

event is not being hit at all. When it hits the event, everything works fine.

Therefore, it seems like its blowing up trying to hit the event.

Any ideas anyone?

Regards,
 
What type of share is this? Is this a MSG file stored in the file system

somewhere, or what?

Does the exception get thrown when the email is opened using code or by the

user or both?

Is that the complete exception you get? Are you doing exception logging and

does this trigger that? Are you handling unhandled exceptions, and if so

does that exception trap fire at all?

"Andrew" <Andrew> wrote in message

news:A0AC6CD6-AEDE-4093-86D5-A6DB06DB8CD9@microsoft.com...
> Hello Folks,

> I have a 2007 Outlook add-in developed in VB.Net which throws the
> following
> error, when an email is attempted to be opened from a share: "Cannot open
> file: "file name and path here." The file may not exist, you may not have
> permission to open it, or it may be open in another program. Right-click
> the
> folder that contains the file, and then click Properties to check your
> permissions for the folder."

> The weird thing is sometimes it opens, but most times it doesn't and
> throws
> that error. The code is written to handle the "NewInspector" event which
> should run when the email is opened. In the times, the error is throw, the
> event is not being hit at all. When it hits the event, everything works
> fine.

> Therefore, it seems like its blowing up trying to hit the event.

> Any ideas anyone?

> Regards,
 
Hey,

Its actually a mapped drive and its an MSG file.

The exception is thrown in both instances.

Yes, that's everything that's thrown when it errors. There is exception

logging, but nothing's being caught by the code. Went through the event log

and there doesn't seem to be anything related there.

As another test, I removed the "application.NewInspector" event and it never

broke, so it seems to be breaking trying to hit the event.
wrote:


> What type of share is this? Is this a MSG file stored in the file system
> somewhere, or what?

> Does the exception get thrown when the email is opened using code or by the
> user or both?

> Is that the complete exception you get? Are you doing exception logging and
> does this trigger that? Are you handling unhandled exceptions, and if so
> does that exception trap fire at all?

> >

>

> "Andrew" <Andrew> wrote in message
> news:A0AC6CD6-AEDE-4093-86D5-A6DB06DB8CD9@microsoft.com...
> > Hello Folks,
> > I have a 2007 Outlook add-in developed in VB.Net which throws the
> > following
> > error, when an email is attempted to be opened from a share: "Cannot open
> > file: "file name and path here." The file may not exist, you may not have
> > permission to open it, or it may be open in another program. Right-click
> > the
> > folder that contains the file, and then click Properties to check your
> > permissions for the folder."
> > The weird thing is sometimes it opens, but most times it doesn't and
> > throws
> > that error. The code is written to handle the "NewInspector" event which
> > should run when the email is opened. In the times, the error is throw, the
> > event is not being hit at all. When it hits the event, everything works
> > fine.
> > Therefore, it seems like its blowing up trying to hit the event.
> > Any ideas anyone?
> > Regards,


>
 
What operating system are you on? Is this Vista?

"Andrew" <Andrew> wrote in message

news:AB63D693-73E1-4EC3-8B8F-BD5DFB0B58A5@microsoft.com...
> Hey,

> Its actually a mapped drive and its an MSG file.

> The exception is thrown in both instances.

> Yes, that's everything that's thrown when it errors. There is exception
> logging, but nothing's being caught by the code. Went through the event
> log
> and there doesn't seem to be anything related there.

> As another test, I removed the "application.NewInspector" event and it
> never
> broke, so it seems to be breaking trying to hit the event.

> " - " wrote:
>
> > What type of share is this? Is this a MSG file stored in the file system
> > somewhere, or what?
>

>> Does the exception get thrown when the email is opened using code or by
> > the
> > user or both?
>

>> Is that the complete exception you get? Are you doing exception logging
> > and
> > does this trigger that? Are you handling unhandled exceptions, and if so
> > does that exception trap fire at all?
>

>> > >

> >

>

>
>
>
>
>
>> "Andrew" <Andrew> wrote in message
> > news:A0AC6CD6-AEDE-4093-86D5-A6DB06DB8CD9@microsoft.com...
> > > Hello Folks,
> >> > I have a 2007 Outlook add-in developed in VB.Net which throws the
> > > following
> > > error, when an email is attempted to be opened from a share: "Cannot
> > > open
> > > file: "file name and path here." The file may not exist, you may not
> > > have
> > > permission to open it, or it may be open in another program.
> > > Right-click
> > > the
> > > folder that contains the file, and then click Properties to check your
> > > permissions for the folder."
> >> > The weird thing is sometimes it opens, but most times it doesn't and
> > > throws
> > > that error. The code is written to handle the "NewInspector" event
> > > which
> > > should run when the email is opened. In the times, the error is throw,
> > > the
> > > event is not being hit at all. When it hits the event, everything works
> > > fine.
> >> > Therefore, it seems like its blowing up trying to hit the event.
> >> > Any ideas anyone?
> >> > Regards,

>

>>
 
Yeah, its Vista!

"Tom" wrote:


> What operating system are you on? Is this Vista?

> "Andrew" <Andrew> wrote in message
> news:AB63D693-73E1-4EC3-8B8F-BD5DFB0B58A5@microsoft.com...
> > Hey,
> > Its actually a mapped drive and its an MSG file.
> > The exception is thrown in both instances.
> > Yes, that's everything that's thrown when it errors. There is exception
> > logging, but nothing's being caught by the code. Went through the event
> > log
> > and there doesn't seem to be anything related there.
> > As another test, I removed the "application.NewInspector" event and it
> > never
> > broke, so it seems to be breaking trying to hit the event.
> > " - " wrote:
> >
> >> What type of share is this? Is this a MSG file stored in the file system
> >> somewhere, or what?
> >
> >> Does the exception get thrown when the email is opened using code or by
> >> the
> >> user or both?
> >
> >> Is that the complete exception you get? Are you doing exception logging
> >> and
> >> does this trigger that? Are you handling unhandled exceptions, and if so
> >> does that exception trap fire at all?
> >
> >> > >>

> >>

> >
> >
> >
> >
> >
> >
> >> "Andrew" <Andrew> wrote in message
> >> news:A0AC6CD6-AEDE-4093-86D5-A6DB06DB8CD9@microsoft.com...
> >> > Hello Folks,
> >> >> > I have a 2007 Outlook add-in developed in VB.Net which throws the
> >> > following
> >> > error, when an email is attempted to be opened from a share: "Cannot
> >> > open
> >> > file: "file name and path here." The file may not exist, you may not
> >> > have
> >> > permission to open it, or it may be open in another program.
> >> > Right-click
> >> > the
> >> > folder that contains the file, and then click Properties to check your
> >> > permissions for the folder."
> >> >> > The weird thing is sometimes it opens, but most times it doesn't and
> >> > throws
> >> > that error. The code is written to handle the "NewInspector" event
> >> > which
> >> > should run when the email is opened. In the times, the error is throw,
> >> > the
> >> > event is not being hit at all. When it hits the event, everything works
> >> > fine.
> >> >> > Therefore, it seems like its blowing up trying to hit the event.
> >> >> > Any ideas anyone?
> >> >> > Regards,
> >
> >>


>
 
I have had similar problems when running from the debugger and and not as an

adminstrator. Be careful on Vista

Simple test ...try this on XP and see if you get the same error.

"Andrew" <Andrew> wrote in message

news:CE710406-3B82-4390-ADED-E971507F2DF7@microsoft.com...
> Yeah, its Vista!

> "Tom" wrote:
>
> > What operating system are you on? Is this Vista?
>

>
>
>> "Andrew" <Andrew> wrote in message
> > news:AB63D693-73E1-4EC3-8B8F-BD5DFB0B58A5@microsoft.com...
> > > Hey,
> >> > Its actually a mapped drive and its an MSG file.
> >> > The exception is thrown in both instances.
> >> > Yes, that's everything that's thrown when it errors. There is exception
> > > logging, but nothing's being caught by the code. Went through the event
> > > log
> > > and there doesn't seem to be anything related there.
> >> > As another test, I removed the "application.NewInspector" event and it
> > > never
> > > broke, so it seems to be breaking trying to hit the event.
> >> > " - " wrote:
> >> >> What type of share is this? Is this a MSG file stored in the file
> > >> system
> > >> somewhere, or what?
> > >
>> >> Does the exception get thrown when the email is opened using code or
> > >> by
> > >> the
> > >> user or both?
> > >
>> >> Is that the complete exception you get? Are you doing exception
> > >> logging
> > >> and
> > >> does this trigger that? Are you handling unhandled exceptions, and if
> > >> so
> > >> does that exception trap fire at all?
> > >
>> >> > > >>

> > >>

> > >
>> >
>> >
>> >
>> >
>> >
>> >> "Andrew" <Andrew> wrote in message
> > >> news:A0AC6CD6-AEDE-4093-86D5-A6DB06DB8CD9@microsoft.com...
> > >> > Hello Folks,
> > >>> >> > I have a 2007 Outlook add-in developed in VB.Net which throws the
> > >> > following
> > >> > error, when an email is attempted to be opened from a share: "Cannot
> > >> > open
> > >> > file: "file name and path here." The file may not exist, you may not
> > >> > have
> > >> > permission to open it, or it may be open in another program.
> > >> > Right-click
> > >> > the
> > >> > folder that contains the file, and then click Properties to check
> > >> > your
> > >> > permissions for the folder."
> > >>> >> > The weird thing is sometimes it opens, but most times it doesn't and
> > >> > throws
> > >> > that error. The code is written to handle the "NewInspector" event
> > >> > which
> > >> > should run when the email is opened. In the times, the error is
> > >> > throw,
> > >> > the
> > >> > event is not being hit at all. When it hits the event, everything
> > >> > works
> > >> > fine.
> > >>> >> > Therefore, it seems like its blowing up trying to hit the event.
> > >>> >> > Any ideas anyone?
> > >>> >> > Regards,
> > >
>> >>

>

>
>>
 
Tested it on an XP machine and the effect was the same, unfortunately!

"Tom" wrote:


> I have had similar problems when running from the debugger and and not as an
> adminstrator. Be careful on Vista

> Simple test ...try this on XP and see if you get the same error.

> "Andrew" <Andrew> wrote in message
> news:CE710406-3B82-4390-ADED-E971507F2DF7@microsoft.com...
> > Yeah, its Vista!
> > "Tom" wrote:
> >
> >> What operating system are you on? Is this Vista?
> >
> >
> >
> >> "Andrew" <Andrew> wrote in message
> >> news:AB63D693-73E1-4EC3-8B8F-BD5DFB0B58A5@microsoft.com...
> >> > Hey,
> >> >> > Its actually a mapped drive and its an MSG file.
> >> >> > The exception is thrown in both instances.
> >> >> > Yes, that's everything that's thrown when it errors. There is exception
> >> > logging, but nothing's being caught by the code. Went through the event
> >> > log
> >> > and there doesn't seem to be anything related there.
> >> >> > As another test, I removed the "application.NewInspector" event and it
> >> > never
> >> > broke, so it seems to be breaking trying to hit the event.
> >> >> > " - " wrote:
> >> >> >> What type of share is this? Is this a MSG file stored in the file
> >> >> system
> >> >> somewhere, or what?
> >> >
> >> >> Does the exception get thrown when the email is opened using code or
> >> >> by
> >> >> the
> >> >> user or both?
> >> >
> >> >> Is that the complete exception you get? Are you doing exception
> >> >> logging
> >> >> and
> >> >> does this trigger that? Are you handling unhandled exceptions, and if
> >> >> so
> >> >> does that exception trap fire at all?
> >> >
> >> >> > >> >>

> >> >>

> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >> "Andrew" <Andrew> wrote in message
> >> >> news:A0AC6CD6-AEDE-4093-86D5-A6DB06DB8CD9@microsoft.com...
> >> >> > Hello Folks,
> >> >> >> >> > I have a 2007 Outlook add-in developed in VB.Net which throws the
> >> >> > following
> >> >> > error, when an email is attempted to be opened from a share: "Cannot
> >> >> > open
> >> >> > file: "file name and path here." The file may not exist, you may not
> >> >> > have
> >> >> > permission to open it, or it may be open in another program.
> >> >> > Right-click
> >> >> > the
> >> >> > folder that contains the file, and then click Properties to check
> >> >> > your
> >> >> > permissions for the folder."
> >> >> >> >> > The weird thing is sometimes it opens, but most times it doesn't and
> >> >> > throws
> >> >> > that error. The code is written to handle the "NewInspector" event
> >> >> > which
> >> >> > should run when the email is opened. In the times, the error is
> >> >> > throw,
> >> >> > the
> >> >> > event is not being hit at all. When it hits the event, everything
> >> >> > works
> >> >> > fine.
> >> >> >> >> > Therefore, it seems like its blowing up trying to hit the event.
> >> >> >> >> > Any ideas anyone?
> >> >> >> >> > Regards,
> >> >
> >> >
> >
> >
> >>


>
 
The only thing I can think of is to start commenting code out until the

condition go's away.

"Andrew" <Andrew> wrote in message

news:92FA6DB8-D37B-49E6-B97A-ADC7BE0CE9C5@microsoft.com...
> Tested it on an XP machine and the effect was the same, unfortunately!

> "Tom" wrote:
>
> > I have had similar problems when running from the debugger and and not as
> > an
> > adminstrator. Be careful on Vista
>

>> Simple test ...try this on XP and see if you get the same error.
>

>
>
>
>
>> "Andrew" <Andrew> wrote in message
> > news:CE710406-3B82-4390-ADED-E971507F2DF7@microsoft.com...
> > > Yeah, its Vista!
> >> > "Tom" wrote:
> >> >> What operating system are you on? Is this Vista?
> > >
>> >
>> >
>> >> "Andrew" <Andrew> wrote in message
> > >> news:AB63D693-73E1-4EC3-8B8F-BD5DFB0B58A5@microsoft.com...
> > >> > Hey,
> > >>> >> > Its actually a mapped drive and its an MSG file.
> > >>> >> > The exception is thrown in both instances.
> > >>> >> > Yes, that's everything that's thrown when it errors. There is
> > >> > exception
> > >> > logging, but nothing's being caught by the code. Went through the
> > >> > event
> > >> > log
> > >> > and there doesn't seem to be anything related there.
> > >>> >> > As another test, I removed the "application.NewInspector" event and
> > >> > it
> > >> > never
> > >> > broke, so it seems to be breaking trying to hit the event.
> > >>> >> > " - " wrote:
> > >>> >> >> What type of share is this? Is this a MSG file stored in the file
> > >> >> system
> > >> >> somewhere, or what?
> > >> >
>> >> >> Does the exception get thrown when the email is opened using code
> > >> >> or
> > >> >> by
> > >> >> the
> > >> >> user or both?
> > >> >
>> >> >> Is that the complete exception you get? Are you doing exception
> > >> >> logging
> > >> >> and
> > >> >> does this trigger that? Are you handling unhandled exceptions, and
> > >> >> if
> > >> >> so
> > >> >> does that exception trap fire at all?
> > >> >
>> >> >> > > >> >>

> > >> >>

> > >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >> "Andrew" <Andrew> wrote in message
> > >> >> news:A0AC6CD6-AEDE-4093-86D5-A6DB06DB8CD9@microsoft.com...
> > >> >> > Hello Folks,
> > >> >>> >> >> > I have a 2007 Outlook add-in developed in VB.Net which throws the
> > >> >> > following
> > >> >> > error, when an email is attempted to be opened from a share:
> > >> >> > "Cannot
> > >> >> > open
> > >> >> > file: "file name and path here." The file may not exist, you may
> > >> >> > not
> > >> >> > have
> > >> >> > permission to open it, or it may be open in another program.
> > >> >> > Right-click
> > >> >> > the
> > >> >> > folder that contains the file, and then click Properties to check
> > >> >> > your
> > >> >> > permissions for the folder."
> > >> >>> >> >> > The weird thing is sometimes it opens, but most times it doesn't
> > >> >> > and
> > >> >> > throws
> > >> >> > that error. The code is written to handle the "NewInspector"
> > >> >> > event
> > >> >> > which
> > >> >> > should run when the email is opened. In the times, the error is
> > >> >> > throw,
> > >> >> > the
> > >> >> > event is not being hit at all. When it hits the event, everything
> > >> >> > works
> > >> >> > fine.
> > >> >>> >> >> > Therefore, it seems like its blowing up trying to hit the event.
> > >> >>> >> >> > Any ideas anyone?
> > >> >>> >> >> > Regards,
> > >> >
>> >> >
>> >
>> >
>> >>

>

>
>>
 
Does this error fire in both run mode and debug mode?

What is your exact code in the NewInspector() event handler?

How is the item being opened, from code or by the user in the UI?

"Andrew" <Andrew> wrote in message

news:AB63D693-73E1-4EC3-8B8F-BD5DFB0B58A5@microsoft.com...
> Hey,

> Its actually a mapped drive and its an MSG file.

> The exception is thrown in both instances.

> Yes, that's everything that's thrown when it errors. There is exception
> logging, but nothing's being caught by the code. Went through the event
> log
> and there doesn't seem to be anything related there.

> As another test, I removed the "application.NewInspector" event and it
> never
> broke, so it seems to be breaking trying to hit the event.
 
Hey,

It fires in every case, Run Mode, Debug mode and when deployed to a machine.

It opens once and then is broken after that.

The email is being opened from a Windows Explorer browser by the user,

double-clicking it.

Here's the initial part of the code that traps the event:

global variable

Dim WithEvents m_olInspectors As Outlook.Inspectors

InspectorWrapper is a custom class

Private Sub m_olInspectors_NewInspector(ByVal Inspector As

Microsoft.Office.Interop.Outlook.Inspector) Handles

m_olInspectors.NewInspector

Dim inspectorWrapper As InspectorWrapper = Nothing

Dim oMailItemTest As Outlook.MailItem = Nothing

Try

> .....

Catch ex As SystemException

MessageBox.Show(ex.Message)

WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event handler failed to

run: " & ex.Message)

Finally

inspectorWrapper = Nothing

oMailItemTest = Nothing

End Try

End Sub

Regards,
wrote:


> Does this error fire in both run mode and debug mode?

> What is your exact code in the NewInspector() event handler?

> How is the item being opened, from code or by the user in the UI?

> >

>

> "Andrew" <Andrew> wrote in message
> news:AB63D693-73E1-4EC3-8B8F-BD5DFB0B58A5@microsoft.com...
> > Hey,
> > Its actually a mapped drive and its an MSG file.
> > The exception is thrown in both instances.
> > Yes, that's everything that's thrown when it errors. There is exception
> > logging, but nothing's being caught by the code. Went through the event
> > log
> > and there doesn't seem to be anything related there.
> > As another test, I removed the "application.NewInspector" event and it
> > never
> > broke, so it seems to be breaking trying to hit the event.


>
 
OK, I did some testing on this and from what I found here it appears that

accessing Inspector.CurrentItem directly or indirectly at all without later

fully releasing that object will cause this error.

For example, assuming your NewInspector() code has just this line in it:

If (TypeOf(Inspector.CurrentItem) Is Outlook.MailItem) Then

That will cause this error.

So will this line:

Dim currentOLItem As Object = Inspector.CurrentItem

However, if you use these lines the problem seems to go away:

Dim currentOLItem As Object = Inspector.CurrentItem

If (TypeOf(currentOLItem) Is Outlook.MailItem) Then

' whatever code you want

End If

Marshal.ReleaseComObject(currentOLItem)

currentOLItem = Nothing

I haven't seen the problem when opening Outlook items within Outlook, it

seems to occur for MSG items however, no matter where they're stored. A

network share or whatever is not required to cause the problem.

See if explicitly instantiating an object for Inspector.CurrentItem so you

have control over it, and then fully releasing it solves the problem for

you. Please post back on your results, if you still have the problem I'll

take it up with the Outlook team.

"Andrew" <Andrew> wrote in message

news:CB6CEABF-A3CD-49B4-9DA0-500728CFBCFF@microsoft.com...
> Hey,

> It fires in every case, Run Mode, Debug mode and when deployed to a
> machine.
> It opens once and then is broken after that.

> The email is being opened from a Windows Explorer browser by the user,
> double-clicking it.

> Here's the initial part of the code that traps the event:

> global variable
> Dim WithEvents m_olInspectors As Outlook.Inspectors
> InspectorWrapper is a custom class

> Private Sub m_olInspectors_NewInspector(ByVal Inspector As
> Microsoft.Office.Interop.Outlook.Inspector) Handles
> m_olInspectors.NewInspector
> Dim inspectorWrapper As InspectorWrapper = Nothing
> Dim oMailItemTest As Outlook.MailItem = Nothing

> Try
> .....
> Catch ex As SystemException
> MessageBox.Show(ex.Message)
> WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event handler failed
> to
> run: " & ex.Message)
> Finally
> inspectorWrapper = Nothing
> oMailItemTest = Nothing
> End Try
> End Sub

> Regards,
 
It's also been bugged to the Outlook team, with a repro found (even in VBA),

and it's being investigated.
<kenslovak@mvps.org> wrote in message

news:O7pci%23dvJHA.4364@TK2MSFTNGP03.phx.gbl...
> OK, I did some testing on this and from what I found here it appears that
> accessing Inspector.CurrentItem directly or indirectly at all without
> later fully releasing that object will cause this error.

> For example, assuming your NewInspector() code has just this line in it:

> If (TypeOf(Inspector.CurrentItem) Is Outlook.MailItem) Then

> That will cause this error.

> So will this line:

> Dim currentOLItem As Object = Inspector.CurrentItem

> However, if you use these lines the problem seems to go away:

> Dim currentOLItem As Object = Inspector.CurrentItem
> If (TypeOf(currentOLItem) Is Outlook.MailItem) Then
> ' whatever code you want
> End If

> Marshal.ReleaseComObject(currentOLItem)
> currentOLItem = Nothing

> I haven't seen the problem when opening Outlook items within Outlook, it
> seems to occur for MSG items however, no matter where they're stored. A
> network share or whatever is not required to cause the problem.

> See if explicitly instantiating an object for Inspector.CurrentItem so you
> have control over it, and then fully releasing it solves the problem for
> you. Please post back on your results, if you still have the problem I'll
> take it up with the Outlook team.

> >

>

> "Andrew" <Andrew> wrote in message
> news:CB6CEABF-A3CD-49B4-9DA0-500728CFBCFF@microsoft.com...
> > Hey,
>

>> It fires in every case, Run Mode, Debug mode and when deployed to a
> > machine.
> > It opens once and then is broken after that.
>

>> The email is being opened from a Windows Explorer browser by the user,
> > double-clicking it.
>

>> Here's the initial part of the code that traps the event:
>

>> global variable
> > Dim WithEvents m_olInspectors As Outlook.Inspectors
> > InspectorWrapper is a custom class
>

>> Private Sub m_olInspectors_NewInspector(ByVal Inspector As
> > Microsoft.Office.Interop.Outlook.Inspector) Handles
> > m_olInspectors.NewInspector
> > Dim inspectorWrapper As InspectorWrapper = Nothing
> > Dim oMailItemTest As Outlook.MailItem = Nothing
>

>> Try
> > .....
> > Catch ex As SystemException
> > MessageBox.Show(ex.Message)
> > WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event handler failed
> > to
> > run: " & ex.Message)
> > Finally
> > inspectorWrapper = Nothing
> > oMailItemTest = Nothing
> > End Try
> > End Sub
>

>> Regards,

>
 
I'm posting the entire block to show the code that's being used. I'm going to

test what you mentioned to see what happens. Will post back in a couple

minutes.

Private Sub m_olInspectors_NewInspector(ByVal Inspector As

Microsoft.Office.Interop.Outlook.Inspector) Handles

m_olInspectors.NewInspector

Dim inspectorWrapper As InspectorWrapper = Nothing

Dim oMailItemTest As Outlook.MailItem = Nothing

Dim strLoginFailed As String = ""

Try

If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then

oMailItemTest = CType(Inspector.CurrentItem, Outlook.MailItem)

'Determine if a New Mail is being composed

If IsNothing(oMailItemTest.EntryID) Then

inspectorWrapper = New InspectorWrapper(Inspector,

inspectorID, False)

'Uses the inspector key to reference the wrapper object

in the collection when added

InspectorList.Add(inspectorWrapper,

CStr(inspectorWrapper.Key), True)

'Increment to give each wrapper object a unique ID

inspectorID += 1

Else

'Web Service call to get client modules

If IsNothing(g_sXMLModules) Then

g_sXMLModules = New XmlDocument

If (g_blnSuccess) Then

g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,

"Outlook"))

Else

AutoLoginClick(True)

WriteLog("clsOutlookAddIn.vb LIne 190: Automatic

logging successfully completed when attempting to load Outlook Modules when

the Modules XML is Nothing!")

If (g_blnSuccess) Then

g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,

"Outlook"))

End If

End If

Else

If

IsNothing(g_sXMLModules.SelectSingleNode("DashboardList/Dashboard")) Then

If (g_blnSuccess) Then

g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,

"Outlook"))

Else

AutoLoginClick(True)

WriteLog("Automatic logging successfully

completed when attempting to load Outlook Modules when the webservice

populates the Modules XML!")

If (g_blnSuccess) Then

g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,

"Outlook"))

End If

End If

End If

End If

inspectorWrapper = New InspectorWrapper(Inspector,

inspectorID, True)

InspectorList.Add(inspectorWrapper,

CStr(inspectorWrapper.Key), False)

inspectorID += 1

End If

End If

Catch ex As SystemException

MessageBox.Show(ex.Message)

WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event

handler failed to run: " & ex.Message)

Finally

inspectorWrapper = Nothing

oMailItemTest = Nothing

Inspector = Nothing

End Try

End Sub
wrote:


> It's also been bugged to the Outlook team, with a repro found (even in VBA),
> and it's being investigated.

> >

>

> " - " <kenslovak@mvps.org> wrote in message
> news:O7pci%23dvJHA.4364@TK2MSFTNGP03.phx.gbl...
> > OK, I did some testing on this and from what I found here it appears that
> > accessing Inspector.CurrentItem directly or indirectly at all without
> > later fully releasing that object will cause this error.
> > For example, assuming your NewInspector() code has just this line in it:
> > If (TypeOf(Inspector.CurrentItem) Is Outlook.MailItem) Then
> > That will cause this error.
> > So will this line:
> > Dim currentOLItem As Object = Inspector.CurrentItem
> > However, if you use these lines the problem seems to go away:
> > Dim currentOLItem As Object = Inspector.CurrentItem
> > If (TypeOf(currentOLItem) Is Outlook.MailItem) Then
> > ' whatever code you want
> > End If
> > Marshal.ReleaseComObject(currentOLItem)
> > currentOLItem = Nothing
> > I haven't seen the problem when opening Outlook items within Outlook, it
> > seems to occur for MSG items however, no matter where they're stored. A
> > network share or whatever is not required to cause the problem.
> > See if explicitly instantiating an object for Inspector.CurrentItem so you
> > have control over it, and then fully releasing it solves the problem for
> > you. Please post back on your results, if you still have the problem I'll
> > take it up with the Outlook team.
> > > >

> >

> > "Andrew" <Andrew> wrote in message
> > news:CB6CEABF-A3CD-49B4-9DA0-500728CFBCFF@microsoft.com...
> >> Hey,
> >
> >> It fires in every case, Run Mode, Debug mode and when deployed to a
> >> machine.
> >> It opens once and then is broken after that.
> >
> >> The email is being opened from a Windows Explorer browser by the user,
> >> double-clicking it.
> >
> >> Here's the initial part of the code that traps the event:
> >
> >> global variable
> >> Dim WithEvents m_olInspectors As Outlook.Inspectors
> >> InspectorWrapper is a custom class
> >
> >> Private Sub m_olInspectors_NewInspector(ByVal Inspector As
> >> Microsoft.Office.Interop.Outlook.Inspector) Handles
> >> m_olInspectors.NewInspector
> >> Dim inspectorWrapper As InspectorWrapper = Nothing
> >> Dim oMailItemTest As Outlook.MailItem = Nothing
> >
> >> Try
> >> .....
> >> Catch ex As SystemException
> >> MessageBox.Show(ex.Message)
> >> WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event handler failed
> >> to
> >> run: " & ex.Message)
> >> Finally
> >> inspectorWrapper = Nothing
> >> oMailItemTest = Nothing
> >> End Try
> >> End Sub
> >
> >> Regards,

> >


>
 
Make sure to fully release any local COM objects you create in that event

handler, don't do that with any class/module/global level COM objects.

"Andrew" <Andrew> wrote in message

news:04A52A5E-160E-4A6B-8873-27EAFE33E492@microsoft.com...
> I'm posting the entire block to show the code that's being used. I'm going
> to
> test what you mentioned to see what happens. Will post back in a couple
> minutes.

> Private Sub m_olInspectors_NewInspector(ByVal Inspector As
> Microsoft.Office.Interop.Outlook.Inspector) Handles
> m_olInspectors.NewInspector
> Dim inspectorWrapper As InspectorWrapper = Nothing
> Dim oMailItemTest As Outlook.MailItem = Nothing
> Dim strLoginFailed As String = ""
> Try
> If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then

> oMailItemTest = CType(Inspector.CurrentItem,
> Outlook.MailItem)

> 'Determine if a New Mail is being composed
> If IsNothing(oMailItemTest.EntryID) Then
> inspectorWrapper = New InspectorWrapper(Inspector,
> inspectorID, False)
> 'Uses the inspector key to reference the wrapper object
> in the collection when added
> InspectorList.Add(inspectorWrapper,
> CStr(inspectorWrapper.Key), True)
> 'Increment to give each wrapper object a unique ID
> inspectorID += 1
> Else
> 'Web Service call to get client modules
> If IsNothing(g_sXMLModules) Then
> g_sXMLModules = New XmlDocument
> If (g_blnSuccess) Then

> g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
> "Outlook"))
> Else
> AutoLoginClick(True)
> WriteLog("clsOutlookAddIn.vb LIne 190:
> Automatic
> logging successfully completed when attempting to load Outlook Modules
> when
> the Modules XML is Nothing!")
> If (g_blnSuccess) Then

> g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
> "Outlook"))
> End If
> End If
> Else
> If
> IsNothing(g_sXMLModules.SelectSingleNode("DashboardList/Dashboard")) Then
> If (g_blnSuccess) Then

> g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
> "Outlook"))
> Else
> AutoLoginClick(True)
> WriteLog("Automatic logging successfully
> completed when attempting to load Outlook Modules when the webservice
> populates the Modules XML!")

> If (g_blnSuccess) Then

> g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
> "Outlook"))
> End If
> End If
> End If
> End If

> inspectorWrapper = New InspectorWrapper(Inspector,
> inspectorID, True)
> InspectorList.Add(inspectorWrapper,
> CStr(inspectorWrapper.Key), False)
> inspectorID += 1
> End If
> End If
> Catch ex As SystemException
> MessageBox.Show(ex.Message)
> WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event
> handler failed to run: " & ex.Message)
> Finally
> inspectorWrapper = Nothing
> oMailItemTest = Nothing
> Inspector = Nothing
> End Try
> End Sub
 
Thanks a lot Ken, that fixed the problem!
wrote:


> Make sure to fully release any local COM objects you create in that event
> handler, don't do that with any class/module/global level COM objects.

> >

>

> "Andrew" <Andrew> wrote in message
> news:04A52A5E-160E-4A6B-8873-27EAFE33E492@microsoft.com...
> > I'm posting the entire block to show the code that's being used. I'm going
> > to
> > test what you mentioned to see what happens. Will post back in a couple
> > minutes.
> > Private Sub m_olInspectors_NewInspector(ByVal Inspector As
> > Microsoft.Office.Interop.Outlook.Inspector) Handles
> > m_olInspectors.NewInspector
> > Dim inspectorWrapper As InspectorWrapper = Nothing
> > Dim oMailItemTest As Outlook.MailItem = Nothing
> > Dim strLoginFailed As String = ""
> > Try
> > If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
> > oMailItemTest = CType(Inspector.CurrentItem,
> > Outlook.MailItem)
> > 'Determine if a New Mail is being composed
> > If IsNothing(oMailItemTest.EntryID) Then
> > inspectorWrapper = New InspectorWrapper(Inspector,
> > inspectorID, False)
> > 'Uses the inspector key to reference the wrapper object
> > in the collection when added
> > InspectorList.Add(inspectorWrapper,
> > CStr(inspectorWrapper.Key), True)
> > 'Increment to give each wrapper object a unique ID
> > inspectorID += 1
> > Else
> > 'Web Service call to get client modules
> > If IsNothing(g_sXMLModules) Then
> > g_sXMLModules = New XmlDocument
> > If (g_blnSuccess) Then
> > g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
> > "Outlook"))
> > Else
> > AutoLoginClick(True)
> > WriteLog("clsOutlookAddIn.vb LIne 190:
> > Automatic
> > logging successfully completed when attempting to load Outlook Modules
> > when
> > the Modules XML is Nothing!")
> > If (g_blnSuccess) Then
> > g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
> > "Outlook"))
> > End If
> > End If
> > Else
> > If
> > IsNothing(g_sXMLModules.SelectSingleNode("DashboardList/Dashboard")) Then
> > If (g_blnSuccess) Then
> > g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
> > "Outlook"))
> > Else
> > AutoLoginClick(True)
> > WriteLog("Automatic logging successfully
> > completed when attempting to load Outlook Modules when the webservice
> > populates the Modules XML!")
> > If (g_blnSuccess) Then
> > g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
> > "Outlook"))
> > End If
> > End If
> > End If
> > End If
> > inspectorWrapper = New InspectorWrapper(Inspector,
> > inspectorID, True)
> > InspectorList.Add(inspectorWrapper,
> > CStr(inspectorWrapper.Key), False)
> > inspectorID += 1
> > End If
> > End If
> > Catch ex As SystemException
> > MessageBox.Show(ex.Message)
> > WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event
> > handler failed to run: " & ex.Message)
> > Finally
> > inspectorWrapper = Nothing
> > oMailItemTest = Nothing
> > Inspector = Nothing
> > End Try
> > End Sub


>
 
Excellent.

At least we have a workaround now until this ends up getting fixed, either

in SP3 or in a hotfix QFE.

"Andrew" <Andrew> wrote in message

news:ABA0EDF8-FDD5-45B1-908F-CB52B79643E5@microsoft.com...
> Thanks a lot Ken, that fixed the problem!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Outlook 2007 crashes when opening an email Using Outlook 2
T Opening email causes "Contacting ..." message Using Outlook 1
Y (Shared Folder) Using the preview pane to open and close a fax, without opening the email itself Using Outlook 1
L Opening up Contact from an Email - Outlook 2007 Using Outlook 15
D problem opening email archives Using Outlook 3
S Attatchments on my email opening up as encoding Using Outlook 4
S URL opening a new email Outlook VBA and Custom Forms 2
M Get the message opening date in the outlook email Outlook VBA and Custom Forms 5
G Email crashes after opening Using Outlook 14
L Opening People Outlook 2021 Using Outlook 2
U When opening shared Calendar "The set of folders cannot be opened" Using Outlook 0
KurtLass Opening Graphics Attachments in Outlook 2021 Using Outlook 0
Witzker Place cursor at opening, a user defined OL contact form Outlook VBA and Custom Forms 3
A OutLook For Mac 16.46 Comes Up In Small Window When Opening Using Outlook 4
U Disable "Always ask before opening" Dialog Using Outlook 3
Wayne Outlook locks up when opening "Manage Rules & Alerts" Using Outlook 7
B Outlook 2010 Opening Mail Attachment Using Outlook 2
A Warning When Opening attachment Using Outlook 7
D Prevent popup of "Do you want to save changes?" when closing after opening an appointment to view Outlook VBA and Custom Forms 2
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
J Outlook 2010 Changing events in Outlook calendar via opening file, importing CSV Using Outlook 0
L What are the risks of opening an Outlook 2016 .pst file in Outlook 2010? Using Outlook 4
A Outlook 2016- unable to have all subfolders expanded when opening outlook Using Outlook 11
GregS Immediate crash on opening Using Outlook 3
Diane Poremsky Error Opening Outlook and Control Panel's Mail Applet Using Outlook 0
S my vbscript button1_click code works on appointment created but not on opening an existing apntmn Outlook VBA and Custom Forms 16
J Opening Attachments - in People Using Outlook 2
Mistyfied Outlook 2016 not opening Using Outlook 2
M Update field codes when opening Outlook Template Outlook VBA and Custom Forms 2
R Outlook PST not opening Using Outlook 1
U .pst file error at opening outlook Using Outlook 1
A Problems Opening Excel from Outlook Outlook VBA and Custom Forms 3
Diane Poremsky Disable the Unsafe Hyperlink Warning when Opening Attachments Using Outlook 0
S macro for opening attachments and printing Using Outlook 1
Z how to make OL (2007) to use custom contact form when importing / opening .VCF? Using Outlook 1
K Outlook 2013 stuck "processing" when opening. Using Outlook 3
S Opening Outlook Windows Using Outlook 1
S PoP up reminder while opening the outlook? Outlook VBA and Custom Forms 1
J Opening/Archiving/Import/Export PST files Using Outlook 4
E OL2007 on Exchange: opening OL on different computers Using Outlook 1
Z outlook 2007 - opening a contact from the search results doesn't use the custom form Using Outlook 10
T Error opening mail with pictures - "The linked image cannot be displayed" Using Outlook 3
P I'm getting an error when opening Outlook "Mobile me stopped working Using Outlook 1
D opening Word Document in a business contact? BCM (Business Contact Manager) 3
B Contact changes from Personal to Shared when opening custom form Using Outlook 0
C How to stop iCloud calendars opening by default Using Outlook 8
U outlook 2010 freezes/crashes when opening encrypted e-mails Using Outlook 0
G OLMAPI32.dII error prevents Outlook 2010 from opening Using Outlook 2
D Custom Tool Bar and/or Commands do not remain when re-opening Outlook 2007 Using Outlook 3
G opening Outlook again after closing closing? Using Outlook 0

Similar threads

Back
Top