Microsoft KB Archive/223745

= OL: Cannot Use the Outlook Object Model to Change the Read Status of a MailItem Object =

Article ID: 223745

Article Last Modified on 2/26/2004

-

APPLIES TO


 * Microsoft Outlook 2000 Standard Edition
 * Microsoft Outlook 2002 Standard Edition

-



This article was previously published under Q223745



SYMPTOMS
You use the Outlook object model to programmatically mark mail messages in the Outbox or Drafts folder as read or unread, but the messages are not changed.



CAUSE
The Outlook object model cannot change the Unread property of a MailItem object if the item has not been sent yet.



WORKAROUND
To work around this issue, use one of the following two methods.

Method 1
Use the Collaboration Data Objects (CDO) 1.21 object model to change the read/unread status of an item.

IMPORTANT: To change the Unread property of an item, you must also set the Sent and Submitted properties. Changes to these properties may result in negative side effects. Test this approach based on your needs and environment.

The following Microsoft Visual Basic for Applications (VBA) code illustrates how to use CDO to change the read/unread state of an item. Make sure that you reference the Microsoft CDO 1.21 Library. Sub AddCDOMessages

Dim objFolder As MAPI.Folder Dim MI As MAPI.Message Dim MI2 As MAPI.Message 'Create and Logon to the MAPI session Set objSession = CreateObject("MAPI.Session") objSession.Logon, , False, False 'Call the Inbox folder Set objFolder = objSession.Inbox 'Add a Read message to the Messages Collection of the Inbox Set MI = objFolder.Messages.Add MI.Subject = "CDO Message 1 - Read" MI.Submitted = True MI.Sent = True MI.UnRead = False MI.Update makePermanent:=True 'Add an Unread message to the Messages Collection of the Inbox Set MI = objFolder.Messages.Add MI.Subject = "CDO Message 2 - Unread" MI.Submitted = True MI.Sent = True MI.UnRead = True MI.Update makePermanent:=True

End Sub

Method 2
If possible, change the read status of the message by using the Outlook user interface (UI). Right-click the message in a folder, and then click Mark As Read or Mark as Unread, depending on the state of the message.



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



MORE INFORMATION
This problem does not occur with other types of items, such as posts or documents.

