I am writing an application that can read email from Outlook (Exchange) inboxes (folders) and then automatically export the email into a separate database for further processing.
The first logical step is to list the inbox and pertaining folders into two comboboxes so the user can select the appropriate inbox and folder. In order to populate this information, I am using the Microsoft.Office.Interop.Outlook namespace
. I have written the following code to pull the listing of inboxes/folders which works perfectly on my development machine (I only have a few inboxes linked to my domain name) but does not work correctly on someone else's machine who has more inboxes than I do:
Dim outlookApplication As New Outlook.Application
Dim mapiNameSpace As Outlook.NameSpace = outlookApplication.GetNamespace("MAPI")
For Each item In mapiNameSpace.Folders
Dim listOfFolders As New List(Of String)
For Each subfolder In item.Folders 'EXCEPTION OCCURS HERE
listOfFolders.Add(subfolder.folderpath.ToString.Replace("\", String.Empty).Replace(item.FolderPath.ToString.Replace("\", String.Empty), String.Empty))
Next subfolder
subFolderDictionary.Add(item.FolderPath.ToString.Replace("\", String.Empty), listOfFolders)
Catch ex As Exception
MsgBox("COULD NOT GET FOLDER INFO: " & ex.ToString)
End Try
Next item
I have indicated in comment above where my exception is occuring (On the For..Each loop on the Namespace MAPI folders. I have attached a picture of the exception: The attempted operation failed. An object could not be found. To be clear, we are all running universal images which contain the same application versions. There was no error in creating the outlook application object or outlook namespace. The error seems to occur when I go to loop the Outlook Namespace MAPI folders.
The other issue here is I do not have the same amount of inboxes that this user does. This user does not have visual studio installed, so debugging on his machine seems out of the question. I am not really sure what I should do in order to remedy this issue as I am not experiencing the issues he is seeing. Changing his configuration at all is out of the question. Any thoughts or previous experience with this issue? How do you begin to debug issues on a machine that you cannot reliably debug on?