Microsoft KB Archive/222484

From BetaArchive Wiki

Article ID: 222484

Article Last Modified on 11/23/2006

This article was previously published under Q222484

SYMPTOMS

You use the Restrict and IncludeRecurrences methods in the Outlook object model and Outlook appears to hang or the collection of items does not appear to be functioning correctly.

CAUSE

This may happen if all of the following are true:

  • You have items that recur and do not have an end date.
  • In the filter of the Restrict method, you used a property that Outlook does not cache by default.
  • In the filter of the Restrict method, you did not specify an end date, so the number of items in the collection is infinite.


RESOLUTION

Use one of the following workarounds:

  • Use the SetColumns method to cache the property you wish to Restrict on. As an example, uncomment the SetColumns line in the "Steps to Reproduce the Problem" section.
  • Alter the filter of the Restrict method so that the method will not return an infinite collection.


STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

Steps to Reproduce the Problem

  1. Create a new Calendar folder.
  2. Create three recurring appointments with a start date of 3/14/99.
  3. On two of the appointments, set the Mileage field to Test. The Mileage field does not appear on the default appointment form, but you can use the Field Chooser to add the field to a table view and then use the in-cell editing feature to set the value.
  4. With the Calendar folder selected, create a reference to the Microsoft Outlook 98 Object Model and run the following Visual Basic Automation code:

    Sub RestrictTest()
        Dim outapp As Outlook.Application
        Dim itms As Outlook.Items
        Dim itmsR As Outlook.Items
        Dim itm As Outlook.AppointmentItem
        Dim strQ As String
        Set outapp = New Outlook.Application
        Set itms = outapp.ActiveExplorer.CurrentFolder.Items
        itms.IncludeRecurrences = True
        itms.Sort "[Start]"
        strQ = "[Mileage] = 'test'"
        Set itmsR = itms.Restrict(strQ)
        'itmsR.SetColumns "Mileage"
        For Each itm In itmsR  '<-- hangs on this line
            If itm.Start > #6/1/1999# Then Exit For
            Debug.Print itm.Subject & " : " & itm.Start & " : " & itm.Mileage
        Next
    End Sub
                        


REFERENCES

For more information about creating solutions with Microsoft Outlook 98, please see the following articles in the Microsoft Knowledge Base:

180826 OL98: Resources for Custom Forms and Programming


182349 OL98: Questions About Custom Forms and Outlook Solutions



Additional query words: OutSol OutSol98 vbscript

Keywords: kbprb KB222484