Inspector.CurrentItem causes Shared Calendar Issue

  • Thread starter ZG90bmV0X290dGF3YQ
  • Start date
Status
Not open for further replies.
Z

ZG90bmV0X290dGF3YQ

I am having a problem with the Inspector.CurrentItem() method causing shared

calendar issues in Outlook 2003. The problem is as follows...

- user 1 and 2 share each others calendar

- user 1 creates a meeting request and sends it to user 2

- user 2 opens the meeting request, changes something [e.g. location] and

sends the update back to user 1

- user 1 sees the meeting request update on the calendar; however, when the

meeting request is opened, the OLD information is displayed, rather than the

updates

I have stripped out all add-in code and narrowed it down to the

Inspector.CurrentItem() method. This method call causes the problem, and

commenting it out makes the problem go away. I however need to test what type

of Outlook object is returned by the Inspector.CurrentItem

My stripped-down code is below.

Any ideas.

**********************************************************

Option Explicit On

Option Strict On

Imports System

Imports Microsoft.Office.Core

Imports System.Runtime.InteropServices

Imports Microsoft.win32

Imports Microsoft.Office.Interop

<GuidAttribute("213CA206-ADED-4C80-A8D6-C2B38E343234"),

ProgIdAttribute("MyAddin.Connect")> _

Public Class Connect

Implements Extensibility.IDTExtensibility2

Private WithEvents inspectors As Outlook.Inspectors

Private applicationObject As Outlook.Application

Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements

Extensibility.IDTExtensibility2.OnBeginShutdown

End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements

Extensibility.IDTExtensibility2.OnAddInsUpdate

End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements

Extensibility.IDTExtensibility2.OnStartupComplete

inspectors = Me.applicationObject.Inspectors

End Sub

Public Sub OnDisconnection(ByVal RemoveMode As

Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements

Extensibility.IDTExtensibility2.OnDisconnection

End Sub

Public Sub OnConnection(ByVal application As Object, ByVal connectMode

As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As

System.Array) Implements Extensibility.IDTExtensibility2.OnConnection

applicationObject = CType(application, Outlook.Application)

End Sub

Private Sub inspectors_NewInspector(ByVal Inspector As

Microsoft.Office.Interop.Outlook.Inspector) Handles inspectors.NewInspector

'this line causes the shared calendar problem

Dim mailItem As Outlook.MailItem = CType(Inspector.CurrentItem,

Outlook.MailItem)

End Sub

End Class

**********************************************************
 
See if this helps.

Instead of trying to instantiate a MailItem object without enclosing it

inside a try...catch block use this type of code:

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

' is a mail item, now instantiate the MailItem object

End If

"dotnet_ottawa" <dotnet_ottawa> wrote in message

news:07602C21-18FD-4D04-8108-B67BC6302A50@microsoft.com...
> I am having a problem with the Inspector.CurrentItem() method causing
> shared
> calendar issues in Outlook 2003. The problem is as follows...

> - user 1 and 2 share each others calendar
> - user 1 creates a meeting request and sends it to user 2
> - user 2 opens the meeting request, changes something [e.g. location] and
> sends the update back to user 1
> - user 1 sees the meeting request update on the calendar; however, when
> the
> meeting request is opened, the OLD information is displayed, rather than
> the
> updates

> I have stripped out all add-in code and narrowed it down to the
> Inspector.CurrentItem() method. This method call causes the problem, and
> commenting it out makes the problem go away. I however need to test what
> type
> of Outlook object is returned by the Inspector.CurrentItem

> My stripped-down code is below.

> Any ideas.

> **********************************************************
> Option Explicit On
> Option Strict On

> Imports System
> Imports Microsoft.Office.Core
> Imports System.Runtime.InteropServices
> Imports Microsoft.win32
> Imports Microsoft.Office.Interop

> <GuidAttribute("213CA206-ADED-4C80-A8D6-C2B38E343234"),
> ProgIdAttribute("MyAddin.Connect")> _
> Public Class Connect
> Implements Extensibility.IDTExtensibility2

> Private WithEvents inspectors As Outlook.Inspectors
> Private applicationObject As Outlook.Application

> Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
> Extensibility.IDTExtensibility2.OnBeginShutdown
> End Sub

> Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
> Extensibility.IDTExtensibility2.OnAddInsUpdate
> End Sub

> Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
> Extensibility.IDTExtensibility2.OnStartupComplete
> inspectors = Me.applicationObject.Inspectors
> End Sub

> Public Sub OnDisconnection(ByVal RemoveMode As
> Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
> Extensibility.IDTExtensibility2.OnDisconnection
> End Sub

> Public Sub OnConnection(ByVal application As Object, ByVal connectMode
> As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom
> As
> System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
> applicationObject = CType(application, Outlook.Application)

> End Sub

> Private Sub inspectors_NewInspector(ByVal Inspector As
> Microsoft.Office.Interop.Outlook.Inspector) Handles
> inspectors.NewInspector
> 'this line causes the shared calendar problem
> Dim mailItem As Outlook.MailItem = CType(Inspector.CurrentItem,
> Outlook.MailItem)
> End Sub

> End Class
> **********************************************************

>
 
Thanks Ken for the quick response.

Actually the code you provided is some of the original code that was used,

and this also causes the problem. It appears that simply calling the

CurrentItem() method is enough.

I have tried many variations including the code from

[http://support.microsoft.com/kb/327657]

Private Sub oInsps_NewInspector(ByVal Inspector As Inspector)

Set lastInspector = Application.Inspectors(Application.Inspectors.Count)

Set objTrustedItem = lastInspector.CurrentItem

End Sub

We are one Service Pack behind on Outlook 2003, we will try this today. I

read an article where the author thought that the Dec 7, 2007 SP would solve

a similar "shared calendar" issue. Will see.

I have not tried creating a wrapper class around everything to see if this

makes a difference.

I just do not understand how such simplistic code can cause this problem. We

will likely contact Microsoft directly, since as far as I can see, the code

should work.
wrote:


> See if this helps.

> Instead of trying to instantiate a MailItem object without enclosing it
> inside a try...catch block use this type of code:

> If (TypeOf(Inspector.CurrentItem) Is Outlook.MailItem) Then
> ' is a mail item, now instantiate the MailItem object
> End If

> >

>

> "dotnet_ottawa" <dotnet_ottawa> wrote in message
> news:07602C21-18FD-4D04-8108-B67BC6302A50@microsoft.com...
> >I am having a problem with the Inspector.CurrentItem() method causing
> >shared
> > calendar issues in Outlook 2003. The problem is as follows...
> > - user 1 and 2 share each others calendar
> > - user 1 creates a meeting request and sends it to user 2
> > - user 2 opens the meeting request, changes something [e.g. location] and
> > sends the update back to user 1
> > - user 1 sees the meeting request update on the calendar; however, when
> > the
> > meeting request is opened, the OLD information is displayed, rather than
> > the
> > updates
> > I have stripped out all add-in code and narrowed it down to the
> > Inspector.CurrentItem() method. This method call causes the problem, and
> > commenting it out makes the problem go away. I however need to test what
> > type
> > of Outlook object is returned by the Inspector.CurrentItem
> > My stripped-down code is below.
> > Any ideas.
> > **********************************************************
> > Option Explicit On
> > Option Strict On
> > Imports System
> > Imports Microsoft.Office.Core
> > Imports System.Runtime.InteropServices
> > Imports Microsoft.win32
> > Imports Microsoft.Office.Interop
> > <GuidAttribute("213CA206-ADED-4C80-A8D6-C2B38E343234"),
> > ProgIdAttribute("MyAddin.Connect")> _
> > Public Class Connect
> > Implements Extensibility.IDTExtensibility2
> > Private WithEvents inspectors As Outlook.Inspectors
> > Private applicationObject As Outlook.Application
> > Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
> > Extensibility.IDTExtensibility2.OnBeginShutdown
> > End Sub
> > Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
> > Extensibility.IDTExtensibility2.OnAddInsUpdate
> > End Sub
> > Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
> > Extensibility.IDTExtensibility2.OnStartupComplete
> > inspectors = Me.applicationObject.Inspectors
> > End Sub
> > Public Sub OnDisconnection(ByVal RemoveMode As
> > Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
> > Extensibility.IDTExtensibility2.OnDisconnection
> > End Sub
> > Public Sub OnConnection(ByVal application As Object, ByVal connectMode
> > As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom
> > As
> > System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
> > applicationObject = CType(application, Outlook.Application)
> > End Sub
> > Private Sub inspectors_NewInspector(ByVal Inspector As
> > Microsoft.Office.Interop.Outlook.Inspector) Handles
> > inspectors.NewInspector
> > 'this line causes the shared calendar problem
> > Dim mailItem As Outlook.MailItem = CType(Inspector.CurrentItem,
> > Outlook.MailItem)
> > End Sub
> > End Class
> > **********************************************************
> >


>
 
Do you see this problem in items opened from non-shared folders (folders the

user owns in their own mailbox)?

How are the shared folders being shared? There are many limitations on items

and folders shared using File, Open, Other User's Folder or by using the

shared calendar module. Usually things only really work right if the shared

folder is in a mailbox that is opened as part of the Outlook profile.

"dotnet_ottawa" <dotnetottawa> wrote in message

news:7AD28168-A91B-48CA-9B30-C2D7C33383BB@microsoft.com...
> Thanks Ken for the quick response.

> Actually the code you provided is some of the original code that was used,
> and this also causes the problem. It appears that simply calling the
> CurrentItem() method is enough.

> I have tried many variations including the code from
> [http://support.microsoft.com/kb/327657]

> Private Sub oInsps_NewInspector(ByVal Inspector As Inspector)
> Set lastInspector =
> Application.Inspectors(Application.Inspectors.Count)
> Set objTrustedItem = lastInspector.CurrentItem
> End Sub

> We are one Service Pack behind on Outlook 2003, we will try this today. I
> read an article where the author thought that the Dec 7, 2007 SP would
> solve
> a similar "shared calendar" issue. Will see.

> I have not tried creating a wrapper class around everything to see if this
> makes a difference.

> I just do not understand how such simplistic code can cause this problem.
> We
> will likely contact Microsoft directly, since as far as I can see, the
> code
> should work.
 
Calendar sharing is set up by clicking the "Share My calendar..." link under

"My calendars" in the Outlook Calendar view. In my case we add 2 users, each

with "Editor" permissions.

So User-X has shared their calendar with User-1 and User-2

User-1 and User-2 go through this process: In Outlook Calendar view, under

the "Other Calendars" section [under "My Calendars"] is User-X Calendar.

Clicking the checkbox will display the User-X Calendar along side the

Calendar of the logged-on user.

1) User-1 creates a meeting request on User-X calendar

2) User-2 edits the meeting request on User-X calendar and sends an update

3) User-1 opens the edited meeting request on User-X calendar, and sees the

original information and NOT the updated information

Without sharing calendars, the process of sending updates to a meeting

request is very different; however, it does work fine.

I have even tried Microsoft's own sample code to create Outlook add-ins

http://msdn.microsoft.com/en-us/library/cc668191.aspx

The sample code also has the same problem. Once the CurrentItem property of

the Inspector is obtained in the NewInspector event, the shared calendar

issue occurs.

Do you know of any other method to determine the type of item referenced by

the CurrentItem property?
wrote:


> Do you see this problem in items opened from non-shared folders (folders the
> user owns in their own mailbox)?

> How are the shared folders being shared? There are many limitations on items
> and folders shared using File, Open, Other User's Folder or by using the
> shared calendar module. Usually things only really work right if the shared
> folder is in a mailbox that is opened as part of the Outlook profile.

> >

>

> "dotnet_ottawa" <dotnetottawa> wrote in message
> news:7AD28168-A91B-48CA-9B30-C2D7C33383BB@microsoft.com...
> > Thanks Ken for the quick response.
> > Actually the code you provided is some of the original code that was used,
> > and this also causes the problem. It appears that simply calling the
> > CurrentItem() method is enough.
> > I have tried many variations including the code from
> > [http://support.microsoft.com/kb/327657]
> > Private Sub oInsps_NewInspector(ByVal Inspector As Inspector)
> > Set lastInspector =
> > Application.Inspectors(Application.Inspectors.Count)
> > Set objTrustedItem = lastInspector.CurrentItem
> > End Sub
> > We are one Service Pack behind on Outlook 2003, we will try this today. I
> > read an article where the author thought that the Dec 7, 2007 SP would
> > solve
> > a similar "shared calendar" issue. Will see.
> > I have not tried creating a wrapper class around everything to see if this
> > makes a difference.
> > I just do not understand how such simplistic code can cause this problem.
> > We
> > will likely contact Microsoft directly, since as far as I can see, the
> > code
> > should work.


>
 
Solution: Inspector.CurrentItem causes Shared Calendar Issue

After speaking with Microsoft Support, my problem is basically a memory leak

issue between .NET and Outlook COM. The original code provided by Microsoft a

few years ago, and continued in Visual Studio 2005 Office add-in does NOT

work perfectly. This code produces a memory leak that can cause instability

in Outlook.

I even tried a wrapper class, but the solution is to use Microsoft wrapper

classes, including a specifc Inspector wrapper class. Although the Microsoft

solution was intended for Outlook 2007 and VS 2005, it is not too difficult

to port this to Outlook 2003 and VS 2003.

See:

http://www.microsoft.com/downloads/...9a-0272-4635-b158-10553779a3df&displaylang=en

I have implemented the Microsoft code and I no longer have my "shared

calendar" issue.

"dotnet_ottawa" wrote:


> Calendar sharing is set up by clicking the "Share My calendar..." link under
> "My calendars" in the Outlook Calendar view. In my case we add 2 users, each
> with "Editor" permissions.

> So User-X has shared their calendar with User-1 and User-2

> User-1 and User-2 go through this process: In Outlook Calendar view, under
> the "Other Calendars" section [under "My Calendars"] is User-X Calendar.
> Clicking the checkbox will display the User-X Calendar along side the
> Calendar of the logged-on user.

> 1) User-1 creates a meeting request on User-X calendar
> 2) User-2 edits the meeting request on User-X calendar and sends an update
> 3) User-1 opens the edited meeting request on User-X calendar, and sees the
> original information and NOT the updated information

> Without sharing calendars, the process of sending updates to a meeting
> request is very different; however, it does work fine.

> I have even tried Microsoft's own sample code to create Outlook add-ins
> http://msdn.microsoft.com/en-us/library/cc668191.aspx

> The sample code also has the same problem. Once the CurrentItem property of
> the Inspector is obtained in the NewInspector event, the shared calendar
> issue occurs.

> Do you know of any other method to determine the type of item referenced by
> the CurrentItem property?

> " - " wrote:
>
> > Do you see this problem in items opened from non-shared folders (folders the
> > user owns in their own mailbox)?
> > How are the shared folders being shared? There are many limitations on items
> > and folders shared using File, Open, Other User's Folder or by using the
> > shared calendar module. Usually things only really work right if the shared
> > folder is in a mailbox that is opened as part of the Outlook profile.
> > > >

> >

> > "dotnet_ottawa" <dotnetottawa> wrote in message
> > news:7AD28168-A91B-48CA-9B30-C2D7C33383BB@microsoft.com...
> > > Thanks Ken for the quick response.
> > > > Actually the code you provided is some of the original code that was used,
> > > and this also causes the problem. It appears that simply calling the
> > > CurrentItem() method is enough.
> > > > I have tried many variations including the code from
> > > [http://support.microsoft.com/kb/327657]
> > > > Private Sub oInsps_NewInspector(ByVal Inspector As Inspector)
> > > Set lastInspector =
> > > Application.Inspectors(Application.Inspectors.Count)
> > > Set objTrustedItem = lastInspector.CurrentItem
> > > End Sub
> > > > We are one Service Pack behind on Outlook 2003, we will try this today. I
> > > read an article where the author thought that the Dec 7, 2007 SP would
> > > solve
> > > a similar "shared calendar" issue. Will see.
> > > > I have not tried creating a wrapper class around everything to see if this
> > > makes a difference.
> > > > I just do not understand how such simplistic code can cause this problem.
> > > We
> > > will likely contact Microsoft directly, since as far as I can see, the
> > > code
> > > should work.

> >
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Outlook 2010 How could I globally redesign an outlook template form/region/inspector template used to display mail lists or an individual mails? Outlook VBA and Custom Forms 0
B Auto Preview Attachment in Inspector Reading Pane Outlook VBA and Custom Forms 1
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
T New Inspector word editor crash Outlook 2003 Outlook VBA and Custom Forms 3
A running code after the new inspector is visible Outlook VBA and Custom Forms 1
N Modal form is not properly working on inspector Outlook VBA and Custom Forms 10
K add a designed group into a existing inspector ribbon Outlook VBA and Custom Forms 7
E Accessing a Form Region from an Inspector Outlook VBA and Custom Forms 3
E Accessing a Form Region from an Inspector Outlook VBA and Custom Forms 3
T How to get Inspector object from Window handle Outlook VBA and Custom Forms 2
K Get Inspector Ptr In Outlook 2007. Outlook VBA and Custom Forms 3
T How to get Inspector or MailItem from wordEditor Outlook VBA and Custom Forms 6
S PR_MESSAGEFLAGS & Compose/Read - Inspector Outlook VBA and Custom Forms 4
S Error 287 on Inspector.Close() Outlook VBA and Custom Forms 4
K Buttons are added multiple times in New Inspector window Outlook VBA and Custom Forms 4
V How to find mailitem in the inspector is a brand new one Outlook VBA and Custom Forms 2
A active inspector in memory Outlook VBA and Custom Forms 1
B How to get the path from an outlook.Inspector Outlook VBA and Custom Forms 4
M How to get active inspector window handle? Outlook VBA and Custom Forms 3
A disable a menu in active inspector Outlook VBA and Custom Forms 1
S inspector toolbar buttons get multiple events Outlook VBA and Custom Forms 3
S Quick access toolbar in inspector window Outlook VBA and Custom Forms 3
T Using Ribbon in Inspector window Outlook VBA and Custom Forms 2
P Inspector.WordEditor always returns null Outlook VBA and Custom Forms 3
Q Inspector Bug/Question Outlook VBA and Custom Forms 3
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
D Application.ActiveInspector().CurrentItem Returns Wrong(Old) Value Outlook VBA and Custom Forms 3
T "Words In Recipient's Address" Rule Causes Outlook To Stop Processing Rules Using Outlook 3
C Synchronizing subscribed folders causes hanging during send/receive process Using Outlook 2
G Windows Update Causes BCM Database Access Problem? BCM (Business Contact Manager) 4
T Opening email causes "Contacting ..." message Using Outlook 1
A Grouping emails using "From" causes a None Category Using Outlook 5
A Outlook 2013 EAS: moving message causes duplicates Using Outlook 3
F Caps causes Outlook 2010 to minimise message in Win8.1 Using Outlook 1
S Outlook 2013. Adding office 365 email account causes 'The operation failed' Using Outlook 2
0 Outlook 2010 causes computer to lose connection when opening and Send/Receive Using Outlook.com accounts in Outlook 14
B Outlook.exe expands to 1.4 mb and causes eratic computer behavior Using Outlook 1
P Minimize button causes Outlook to close 2007 Using Outlook 1
R Enabling OutlookAnywhere in ClientAccess role causes inaccessible RemoteDesktop Gateway Server Exchange Server Administration 2
A COM add-in causes Outlook 2007 to periodically crash where it did not in Outlook 2003 Outlook VBA and Custom Forms 3

Similar threads

Back
Top