none
Implementing a container for appointments RRS feed

  • Question

  •  

    Hi,

    I am following Damian advice from a different post,

    I am trying to save appointments item into a Class, the class get populated on start up.

    I am simulating a scenario, in which there are over 5000 appointment to be added,

    In this case it takes 5-6 second to populate the class I was wondering way it takes so much time?

    Maybe the implementation is wrong..?

    One more thought, does the AppointmentItem.EntryID changes when closing outlook?

    If not,  I don’t need a container to run at start up every time, I can save EntryID at local DB?

    Any suggestions will be most appreciated.

    Tanks,

    Patrick

    Snippit:

     Public Shared AppointmentList As AppointmentItemList
    Private Sub ThisAddIn_Startup() Handles Me.Startup
    AppointmentList = New AppointmentItemList()
    Dim outlookNamespace As Outlook.NameSpace = Me.Application.GetNamespace("MAPI")
                Dim calendar As Outlook.MAPIFolder = outlookNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
                'release com object
                CalendarItem = calendar.Items
     	    Dim obj As Object
                For Each obj In CalendarItem
                    If TypeOf obj Is Outlook.AppointmentItem Then
                        If obj.Start >= Today Then
                          ThisAddIn.AppointmentList.AddAppointment(obj.Subject, obj.EntryID, obj.Start, obj.End)
                        End If
                    End If
                Next
    end sub
    Public Class AppointmentClass
        Private Subject As String
        Private EntryID As String
        Private StartTime As Date
        Private EndTime As Date
        Public Property AppointmentEntryID As String
            Get
                Return EntryID
            End Get
            Set(ByVal value As String)
                EntryID = value
            End Set
        End Property
        Public Property AppointmentSubject  As String
            Get
                Return Subject 
            End Get
            Set(ByVal value As String)
                Subject = value
            End Set
        End Property
        Public Property AppointmentStartTime As Date
            Get
                Return StartTime
            End Get
            Set(ByVal value As Date)
                StartTime = value
            End Set
        End Property
        Public Property AppointmentEndTime As Date
            Get
                Return EndTime
            End Get
            Set(ByVal value As Date)
                EndTime = value
            End Set
        End Property
        Public Sub New(ByVal AppointmentSubject As String, ByVal AppointmentEntryID As String, ByVal StartTime As Date, ByVal EndTime As Date)
            Subject = AppointmentSubject
            EntryID = AppointmentEntryID
            StartTime = StartTime
            EndTime = EndTime
        End Sub
    End Class
    Public Class AppointmentItemList
        Inherits System.Collections.CollectionBase
        Private AppointmentItem As AppointmentClass
        Public Sub New()
            AppointmentItem = Nothing
        End Sub
        Public Sub AddAppointment(ByVal AppointmentSubject As String, ByVal AppointmentEntryID As String, ByVal StartTime As Date, ByVal EndTime As Date)
            AppointmentItem = New AppointmentClass(AppointmentSubject, AppointmentEntryID, StartTime, EndTime)
            Me.List.Add(AppointmentItem)
        End Sub
        Default Public ReadOnly Property Item(ByVal Index As Integer) As AppointmentClass
            Get
                Return CType(Me.List.Item(Index), AppointmentClass)
            End Get
        End Property
        Public Sub RemoveByIndex(ByVal Index As Integer)
            If Me.Count > 0 Then
                Me.List.RemoveAt(Index)
            End If
        End Sub
        Public Sub RemoveByEntryID(ByVal AppointmentEntryID As String)
            Dim i As Integer
            For i = 1 To Me.Count - 1
                If Item(i).AppointmentEntryID.Equals(AppointmentEntryID) Then
                    Me.List.RemoveAt(i)
                    Return
                End If
            Next
        End Sub
    End Class

    Tuesday, March 27, 2012 8:07 AM

Answers

  • few suggestions:

    1. if there are so much items that you need to process in OOM, either display something to user so he will know that outlook did not hang or take only few, process them and repeat

    2. consider using GetTable method for faster access using overload with filter so you get only items starting today or later and clear columns and set only those that you need http://msdn.microsoft.com/en-us/library/ff860692.aspx

    3. you can cache entryids in external source, but remember that due to user's actions and or rules, external code, whatever, they can change (for example when item is moved).

    • Marked as answer by Patrick12_3 Tuesday, March 27, 2012 10:32 AM
    Tuesday, March 27, 2012 9:02 AM

All replies

  • few suggestions:

    1. if there are so much items that you need to process in OOM, either display something to user so he will know that outlook did not hang or take only few, process them and repeat

    2. consider using GetTable method for faster access using overload with filter so you get only items starting today or later and clear columns and set only those that you need http://msdn.microsoft.com/en-us/library/ff860692.aspx

    3. you can cache entryids in external source, but remember that due to user's actions and or rules, external code, whatever, they can change (for example when item is moved).

    • Marked as answer by Patrick12_3 Tuesday, March 27, 2012 10:32 AM
    Tuesday, March 27, 2012 9:02 AM
  •   Hi Damian,

    Tank you for replaying..

     

    3. you can cache entryids in external source, but remember that due to user's actions and or rules, external code, whatever, they can change (for example when item is moved).

    User actions i can handle, remove by EntryID ... if item removed but other actions? When item moves to different time? Does EntryID changes?

    Patrick

    Tuesday, March 27, 2012 9:12 AM
  • i do not think that entry id changes when start or end time for appointmnet changes, but:

    1. remembet that you write only add-in, you do not own outlook process, your add-in can be disabled, etc. and so you cannot bu sure to 'handle' user actions as they can be done outside of your add-in's control (also in OWA)

    2. remember that users can for example add exceptions to recurring events - this way new calendar item will be created and if you only depend on cached values you will miss it

    Tuesday, March 27, 2012 9:59 AM
  •  

    Tanks again Damian I appreciate your Help

     

    PatricK

    Tuesday, March 27, 2012 10:32 AM
  • When and if an EntryID changes depends on the store provider.
     
    For example, with a PST file the EntryID does not change when the item is moved within the PST file or when it's deleted. For an Exchange mailbox the EntryID will change when the item is moved or deleted. Moving an item from one store to another always changes the EntryID.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:d69fe833-9a49-4e06-acd6-adc113c67c28...

    i do not think that entry id changes when start or end time for appointmnet changes, but:

    1. remembet that you write only add-in, you do not own outlook process, your add-in can be disabled, etc. and so you cannot bu sure to 'handle' user actions as they can be done outside of your add-in's control (also in OWA)

    2. remember that users can for example add exceptions to recurring events - this way new calendar item will be created and if you only depend on cached values you will miss it


    Ken Slovak MVP - Outlook
    Tuesday, March 27, 2012 1:27 PM
    Moderator