Slow Switching of Email

Add-in Express™ Support Service
That's what is more important than anything else

Slow Switching of Email
 
SSL




Posts: 178
Joined: 2014-01-05
I have a user who has added around 6 additional inboxes to outlook, which has caused email switching to be really slow, if I disable the addin its fine.

All inboxes linked to online exchange account

Any thoughts

Regards,
Tom
Posted 01 Oct, 2015 05:52:47 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Tom,

Possibly, this belongs to your code. Did you try checking an Add-in Express add-in with no code at all? If the empty add-in produces no harm, then check the events that occur when performing "email switching" (whatever it means). Also, you can test our Outlook Events Logger add-in in this scenario, see https://www.add-in-express.com/creating-addins-blog/2010/07/01/outlook-events-tool/.


Andrei Smolin
Add-in Express Team Leader
Posted 01 Oct, 2015 06:34:13 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

Have installed Outlook Events Logger:

Without Addin Installed
= 13:09:00 = ADXOutlookAppEvents.ExplorerSelectionChange. Current Folder name is 'Inbox', Explorer caption is 'Inbox - me@me.me - Outlook'
= 13:09:00 = ADXOutlookAppEvents.ItemLoad.
= 13:09:00 = ADXOutlookAppEvents.ExplorerSelectionChange. Current Folder name is 'Inbox', Explorer caption is 'Inbox - me@me.me - Outlook'
= 13:09:00 = ADXOutlookAppEvents.ItemLoad.
= 13:09:00 = ADXOutlookItemEvents.Read. MailItem with subject 'ME'.


With Addin Installed
= 13:09:41 = ADXOutlookAppEvents.ExplorerSelectionChange. Current Folder name is 'Inbox', Explorer caption is 'Inbox - me@me.me - Outlook'
= 13:09:49 = ADXOutlookAppEvents.ExplorerSelectionChange. Current Folder name is 'Inbox', Explorer caption is 'Inbox - me@me.me - Outlook'
= 13:09:49 = ADXOutlookItemsEvents.ItemChange MailItem with subject 'ME' Parent Folder name is Inbox.
= 13:09:49 = ADXOutlookItemsEvents.ItemChange MailItem with subject 'ME' Parent Folder name is Inbox.

Will try running with no code at all.

Regards,
Tom
Posted 01 Oct, 2015 07:21:02 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Tom,

Any news?


Andrei Smolin
Add-in Express Team Leader
Posted 02 Oct, 2015 03:15:49 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

I made some changes and all seems fine now, I switched some code between itemLoad and ExplorerSelectionChange which has speeded things up now.

Regards,

Tom
Posted 07 Oct, 2015 03:31:51 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Thank you!


Andrei Smolin
Add-in Express Team Leader
Posted 07 Oct, 2015 03:41:34 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

One more question regarding this issue, I am writing user properties to certain emails, if a user has only their inbox showing, writing user properties is instant (on another PC a user has access to 8 other inboxes over Exchange online, it takes around 12 seconds for the user properties to be added to the email)

Do you have any thoughts on this?

Regards,

Tom
Posted 26 Oct, 2015 11:33:45 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Tom,

SSL writes:
Do you have any thoughts on this?


I suppose the time is mostly spent on getting the emails, not on setting the user properties. Say, I would expect this to occur if you use NameSpace.GetItemFormId() and doesn't specify the second parameter.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Oct, 2015 02:29:24 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

It was down to this function, that Sergey Provided:

 Public Function fnGetFolderIDs(folderType As Outlook.OlDefaultFolders) As String

        Dim result As String = Nothing

        Dim ns As Outlook._NameSpace = Solution_Outlook.AddinModule.CurrentInstance.OutlookApp.GetNamespace("MAPI")
        If ns IsNot Nothing Then
            Try

                Dim stores As Outlook._Stores = ns.Stores
                If stores IsNot Nothing Then
                    Try

                        ' more than 1 account - scan the Stores collection and find folders by name
                        If stores.Count > 1 Then

                            ' get name
                            Dim folder As Outlook.MAPIFolder = ns.GetDefaultFolder(folderType)
                            Dim folderName As String = folder.Name
                            Marshal.ReleaseComObject(folder)

                            ' and scan
                            For i As Integer = 1 To stores.Count
                                Try
                                    Dim store As Outlook._Store = stores(i)
                                    If store IsNot Nothing Then
                                        Try
                                            Dim root As Outlook.MAPIFolder = store.GetRootFolder()
                                            If root IsNot Nothing Then
                                                Try
                                                    Dim subfolders As Outlook._Folders = root.Folders
                                                    If subfolders IsNot Nothing Then
                                                        Try

                                                            Dim targetFolder As Outlook.Folder = CType(subfolders(folderName), Outlook.Folder)
                                                            If targetFolder IsNot Nothing Then
                                                                result = targetFolder.EntryID
                                                                GetSubFolderIDs(targetFolder, result)
                                                                Marshal.ReleaseComObject(targetFolder)
                                                            End If

                                                        Finally
                                                            Marshal.ReleaseComObject(subfolders)
                                                        End Try
                                                    End If
                                                Finally
                                                    Marshal.ReleaseComObject(root)
                                                End Try
                                            End If
                                        Finally
                                            Marshal.ReleaseComObject(store)
                                        End Try
                                    End If
                                Catch
                                    ' some stores (e.g. Public Folders) may not contain default folders
                                    ' skip the "The attempted operation failed.  An object could not be found." exception
                                End Try
                            Next

                        Else
                            ' single account, we can use the default approach
                            Dim folder As Outlook.MAPIFolder = ns.GetDefaultFolder(folderType)
                            If folder IsNot Nothing Then
                                result = folder.EntryID
                                GetSubFolderIDs(CType(folder, Outlook.Folder), result)
                                Marshal.ReleaseComObject(folder)
                            End If
                        End If

                    Finally
                        Marshal.ReleaseComObject(stores)
                    End Try
                End If

            Finally
                Marshal.ReleaseComObject(ns)
            End Try
        End If


        Return result

    End Function


Basically I was using it to determine weather a selected folder was an inbox folder and any sub folders also.

Is there any other way to do this
As soon as I took out this function, adding user properties was instant.
Posted 27 Oct, 2015 07:05:10 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Tom,

How does this function relate to the issue? I don't see the whole picture.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Oct, 2015 10:07:24 Top