Why is this stopping?
Posted on 2006-06-20
I'm trying to write a tool to retrieve all my Outlook 2003 appointments for me. At this point, I'm just in the start of a test tool. I've got a form with a listbox on it named ListBox1 into which I want to add all these. Once I have this working it's on to the next step.
I'm running the following and I'm being told I have > 1000 appointments (which I do). However, when I run this I get through about a dozen and then it goes off into never land. The thumbwheel on the ListBox shrinks to nothing and the program doesn't return. It's appearently gotten into some sort of fatal loop (and yet I'm not getting any exception).
Any thoughts? I'm just looking for some code that will list all the subjects of all my appointments.
Dim oApp As Outlook.Application = New Outlook.Application()
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNS.Logon("YourValidProfile", Missing.Value, False, True)
Dim oCalendar As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Dim oAppointments As Outlook.Items = oCalendar.Items
MsgBox("Total : " & oAppointments.Count)
Dim oAppt As Outlook.AppointmentItem = Nothing
oAppt = oAppointments.GetFirst
While oAppt IsNot Nothing
If Len(oAppt.Subject) = 0 Then
oAppt = oAppointments.GetNext
Catch ex As Exception
MsgBox(ex.Message & " " & ex.StackTrace)