Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect Whether a Message was Read

Status
Not open for further replies.

hilbertl3

Technical User
Sep 22, 2004
77
US
Is there a way to tell whether or not a message in a public folder has been opened by anyone?
I'd like a property that exposes this info using VB.

Thanks,

Hilbert Lindo
 
Using the Outlook Object Model, the Unread property of an item can be used to determine this.

e.g

Code:
If item.unread = False then
    'the message has been read
End if

Does that help?


 
Thanks for your reply. I know about this, but the read or unread status varies by user. So for one user the item may have a read status and for another an unread status depending on whether or not it was opened. I want to know if the message was read by anyone, not just a particular user.
 
OK, I understand now. I'm not sure if you're in a position to change the setting, but this behaviour is controlled by an option on the public folder. If you're not aware, the option is set on the folder properties from the public folder heirarchy in the ESM - you'll see on the first tab there is an option for "Maintain per-user read and unread information for this folder". It's checked by default.

Otherwise, you may need to explore doing it via CDO so that you're not accessing the folder using a particular user's mailbox (and hence suffering from to the varying read/unread status).

 
I need to run this procedure on an existing
group of public folders/messages so I guess option 1 would not help. How could I do it by CDO?
 
I tested with CDO and unfortunately becuase you're logging into the server with a particular mailbox, it only reflects the read/unread status for that user - just like when using the Outlook Object Model.

Here's the code I tested with. I copied most of it from CDOLive I've removed my server information and public folders.

Code:
' Create MAPI session
Dim objSession
Set objSession = CreateObject("MAPI.Session")

' Or, logon using an new MAPI session with a dynamically created profile
strProfileInfo = "FQDN of your ExchangeServer" & vbLf & "Your Mailbox alias"
objSession.Logon "", "", False, True, 0, False, strProfileInfo 


'MAPI property to access the public folder subtree
Public Const PR_IPM_PUBLIC_FOLDERS_ENTRYID = &H66310102

' Get InfoStore collection
Set objInfoStores = objSession.InfoStores

' Loop through the collection until we have found the public information store
' Only this infostore will return the indicated property without error
For Each objInfoStore In objInfoStores
  Err.Clear
  strRootID =_
    objInfoStore.Fields(PR_IPM_PUBLIC_FOLDERS_ENTRYID).Value

  ' Check or possible errors
  If Err.Number = 0 Then

    ' Get root folder
    Set objTopFolder = objSession.GetFolder(strRootID, objInfoStore.ID)
    Exit For
  End If
Next

' Get your folder
Set objFolder = _
objTopFolder.Folders("Folder under All Public Folders").Folders("Next Folder").Folders("Next Folder").Folders("Folder you want to work with")

'Once you have access to that folder, you can work with the items like you want:
Set objMessages = objFolder.Messages

For Each item in objMessages
	If item.Unread = "True" then
		wscript.echo item.subject
	End If
Next

' Logoff from MAPI Session
objSession.Logoff

Without changing the option on the folder, I'm note sure how to acheive this. Anyone else?

Ben.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top