Microsoft KB Archive/239658

From BetaArchive Wiki

Article ID: 239658

Article Last Modified on 3/1/2004



APPLIES TO

  • Microsoft Outlook 98 Standard Edition



This article was previously published under Q239658

IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry


SYMPTOMS

You use the Outlook object model to loop through items in a folder, but run into memory limitations, or the amount of time that it takes to process an item increases as the collection of items is processed.

CAUSE

The items are based on a custom form that uses Visual Basic Scripting Edition (VBScript), and Outlook does not release memory related to VBScript until the entire collection of items is processed.

RESOLUTION

To resolve this problem, obtain a hotfix that is available. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

238383 OL98: Script Enumerating Many Items May Use Large Memory Block


NOTE: This same fix is included in Outlook 2000 Service Release 1 (SR1), so consider upgrading to that version instead of applying a hotfix.

After you apply the hotfix, you must add a registry key to limit the number of times Outlook loads the VBScript.

WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.


Create the following DWORD registry key, and then set its value to a number greater than 0:

HKEY_LOCAL_MACHINE\Software\Microsoft\Office\8.0\Outlook\Scripting\Threshold


Outlook limits the number of simultaneous script objects to that number. You can set it to any small number, which allows most looping scenarios to run. However, Microsoft recommends you set it to a value in the range of 10 to 20 because after you implement this registry key, custom forms that are opened through the Outlook user interface are also affected. For example, if you set the value to 2, and then open three custom forms with VBScript in them, the VBScript code will not run in the third item you open.

WORKAROUND

Depending on what types of items you are processing and what fields you need to access, you may be able to use the Collaboration Data Objects (CDO) object model to access the items instead of the Outlook object model.

STATUS

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

MORE INFORMATION

Steps to Reproduce Problem

NOTE: Use a Microsoft Window NT or Microsoft Windows 2000-based computer so that you can later see memory usage by using the Windows Task Manager.

  1. Create a custom contact form in your default Contacts folder, and then add a custom command button to it.
  2. Add the following VBScript code:

    Sub CommandButton1_Click()
       ' Get a reference to the default contacts folder
       Set objFolder = GetNamespace("MAPI").GetDefaultFolder(10)
       MsgBox "Start loop"
       For i = 1 to objFolder.Items.Count
          Set objItm = objFolder.Items(i)
          ' After this assignment, the memory is allocated
          strTemp = objItm.Fullname
          ' if objItm contains no VBScript code, it is freed here 
          Set objItm = Nothing 
          Set strTemp = Nothing
       Next
       MsgBox "Loop ended successfully."
    End Sub
                        
  3. Create several hundred items in the folder based on the custom form.
  4. Open one of the items, and then click the command button to run the code.
  5. Open the Windows Task Manager, and you should see Outlook memory usage increasing.


REFERENCES

For additional information about creating solutions with Microsoft Outlook, click the article numbers below to view the 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

Keywords: kbbug kbfix KB239658