OL2000: Can't Display or Save Item Using GetItemFromID

ID: Q228512


The information in this article applies to:
  • Microsoft Outlook 2000


SYMPTOMS

You try to programmatically display or save an item, but the Display or Save methods in the Outlook object model do not seem to work.


CAUSE

This behavior occurs when all of the following conditions are true:

  • You referenced the item using the GetItemFromID method.


  • -and-

  • The item is based on a custom form containing Visual Basic Scripting Edition (VBScript) code.


  • -and-

  • The form definition is not stored within the item.



RESOLUTION

Depending on the needs of your solution, you may be able to work around the problem by using an alternate method of referencing the item. For additional information about how to programmatically reference items, please see the following article in the Microsoft Knowledge Base:

Q208520 OL2000: Programming Examples for Referencing Items and Folders


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

This problem is not related to the type of folder the items are stored in. The problem occurs regardless of whether the folder is stored in a Personal Folders (.pst) file, Microsoft Exchange public folders, or a Microsoft Exchange mailbox.

Steps to Reproduce Behavior

  1. Create a new folder, in this case a Contacts folder.


  2. Open a new contact.


  3. On the Tools menu, point to Forms, and then click Design This Form.


  4. On the Form menu, click View Code. Enter the following VBScript code into the Script Editor and then close the Script Editor:


  5. 
    Dim x 
  6. On the Tools menu, point to Forms, and then click Publish Form. The default is to store the Contact form in the folder you created in step 1. Type GetItemFromID Test1 as the Display Name, and then click Publish.


  7. Close and do not save changes to the form.


  8. On the Actions menu, click New GetItemFromID Test1. Enter some contact information and save the contact.


  9. Open a new, default contact.


  10. On the Tools menu, point to Forms, and then click Design This Form.


  11. Click the P.2 page of the form.


  12. On the Form menu, click Control Toolbox. Drag a CommandButton control onto the P.2 page of the form.


  13. On the Form menu, click View Code. Enter the following VBScript code into the Script Editor and then close the Script Editor:


  14. 
    Sub CommandButton1_Click()
       Dim ns, myFolder, myItem, myEntryID, myStoreID
       Set ns = Application.GetNamespace("MAPI")
       Set myFolder = Application.ActiveExplorer.CurrentFolder
       Set myItem = myFolder.Items(1)
       MsgBox "First item in folder: " & myItem.Subject
       myEntryID = myItem.EntryID
       myStoreID = myItem.Parent.StoreID
       Set myItem = Nothing
       Set myItem = ns.GetItemFromID(myEntryID, myStoreID)
       MsgBox "Item found using GetItemFromID: " & myItem.Subject
       myItem.Display
       Set myItem = Nothing
       Set myFolder = Nothing
       Set ns =  Nothing
    End Sub  
  15. On the Tools menu, point to Forms, and then click Publish Form. The default is to store the Contact form in the folder you created in step 1. Type GetItemFromID Test2 as the Display Name, and then click Publish.


  16. Close and do not save changes to the form.


  17. On the Actions menu, click New GetItemFromID Test2. Switch to the P.2 page of the form and click the CommandButton.


Result: You receive two message boxes indicating that Outlook has referenced the first item in the folder, but then the item is not displayed.


REFERENCES

For additional information about saving the form definition with an item, please see the following article in the Microsoft Knowledge Base:

Q207896 OL2000: Working with Form Definitions and One-Off Forms
For additional information about available resources and answers to commonly asked questions about Microsoft Outlook 2000 solutions, please see the following article in the Microsoft Knowledge Base:
Q146636 OL2000: Questions About Custom Forms and Outlook Solutions

Additional query words: kbMsg kbOutlook98bug kbOutlookObj kbGrpMsg OutSol OutSol2000 vbscript

Keywords : kbMsg kbOutlook98bug kbOutlookObj kbGrpMsg
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: August 12, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.