OL98: Restrict Method Doesn't Work with GetSharedDefaultFolder

ID: Q183897

The information in this article applies to:

SYMPTOMS

In the Microsoft Outlook 98 object model, you use the Restrict method to retrieve a subset of items from a delegated folder, but all of the items in the folder are returned.

CAUSE

In order for the Restrict method to work with a delegated folder, you must be retrieving appointments from a shared calendar and you must use the IncludeRecurrences and Sort methods to make sure that all of the appointments are retrieved.

If you use the Restrict method on other folder types, such as a delegated contacts folder, the Restrict method will not function correctly.

WORKAROUND

If the Restrict method is not functioning based on your solution's need, you can use the Find and FindNext methods to retrieve items one at a time.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Outlook 98.

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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

The Restrict method is used to return a subset of a collection of items based on certain criteria.

The GetSharedDefaultFolder method is used to gain access to someone else's folder after they have given you delegate access to their folder.

The Restrict method does function correctly when used on your own folder or a Microsoft Exchange public folder.

The following Microsoft Visual Basic or Visual Basic for Applications automation code illustrates how the Restrict method can work with a delegated Calendar folder.

   Sub Bug()
      Set ol = New Outlook.Application
      Set olns = ol.GetNamespace("MAPI")
      Set MyRecip = olns.CreateRecipient("John Smith")
      MyRecip.Resolve
      Set MyFolder = olns.GetSharedDefaultFolder(MyRecip, olFolderCalendar)
      Set MyItems = MyFolder.Items
      MyItems.Sort "[Start]"
      MyItems.IncludeRecurrences = True
      MyClause = "[Subject] = " & Chr(34) & "Christmas Day" & Chr(34)
      Set MyResItems = MyItems.Restrict(MyClause)
      MsgBox MyResItems.Count
      For Each MyItem In MyResItems
         MsgBox MyItem.Subject
      Next
   End Sub

REFERENCES

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

   ARTICLE-ID: Q180826
   TITLE     : OL98: Resources for Custom Forms and Programming

   ARTICLE-ID: Q182349
   TITLE     : OL98: Questions About Custom Forms and Outlook Solutions

Additional query words: OutSol OutSol98
Keywords          : kbprg kbdta 
Version           : WINDOWS:98
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: May 17, 1999