PRB: CDO (1.x) Cannot See New Incoming Messages in Personal Folders (195380)



The information in this article applies to:

  • Collaboration Data Objects (CDO) 1.1
  • Collaboration Data Objects (CDO) 1.2
  • Collaboration Data Objects (CDO) 1.21

This article was previously published under Q195380

SYMPTOMS

If you designate a Personal Folders store as the delivery location for your incoming messages, your Collaboration Data Objects (1.1, 1.2, 1.21) application fails to see new incoming messages.

CAUSE

The new mail has not been transferred to the Personal Folders store yet. CDO (1.1, 1.2, 1.21) does not register for server notifications, therefore, delivery of the new messages to the Personal Folders store does not occur automatically.

RESOLUTION

Following are two alternatives:
  • Run Microsoft Outlook before processing the new messages in your CDO (1.1, 1.2, 1.21) code. The server advises Microsoft Outlook when new mail arrives, which results in the transfer of new messages to the Personal Folders store.

    -or-
  • Use the DeliverNow method of the CDO (1.1, 1.2, 1.21) Session object before referring to any message item in your Inbox. The DeliverNow method requests the Messaging Application Programming Interface (MAPI) Spooler to deliver all messages in the inbound queues immediately.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Set mail delivery to a Personal Folders file. For more information on how to accomplish this task, please refer to the article listed in the REFERENCES section.
  2. Start a New Project in Microsoft Visual Basic. Make a reference to the Microsoft CDO (1.1, 1.2, 1.21) Library.
  3. Add the following code to the Sub Form_Load() event procedure:
          Dim objSession As MAPI.Session
          Dim objMsgColl As Messages
          Dim objMsg As Message
          Dim objInbox As Folder
          'Create the Session then Logon.
          Set objSession = CreateObject("MAPI.Session")
          objSession.Logon "YourProfileName" 'TO DO: Enter a valid profilename
          Set objInbox = objSession.Inbox
    
          'Note: DeliverNow should be called after accessing the store,
          '      otherwise it will have no effect.
          ' objSession.DeliverNow
    
          Set objMsgColl = objInbox.Messages
          For Each objMsg In objMsgColl
             MsgBox "Subject: " & objMsg.Subject
          Next
          Set objMsg = Nothing
          Set objMsgColl = Nothing
          Set objInbox = Nothing
          objSession.Logoff
          Set objSession = Nothing
    					
  4. Make sure that Microsoft Outlook is not running on your computer.
  5. Have somebody send a message to you. Run the preceding program by pressing the F5 key. Confirm that the program did not display the subject of the new message.
  6. Either uncomment the line "objSession.DeliverNow" or run Microsoft Outlook and logging into the same profile that you have in the code. Run the program. Confirm that you see the subject of the new message.

REFERENCES

For more information on setting mail delivery to a Personal Folders file, please see the following article in the Microsoft Knowledge Base:

182062 OL98: Working with Personal Folders


Modification Type:MinorLast Reviewed:3/4/2004
Keywords:kbMsg kbprb KB195380