Platform SDK: Exchange 2000 Server

Listing Inbox Contents Using ADO

[This is preliminary documentation and subject to change.]

The following example demonstrates how to create a common item listing of a user's inbox. This list, or "view," is normally presented when a user selects a folder in their mailbox containing messages.

[Visual Basic]
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Server Library
' ..
Dim Rec   as New ADODB.Record
Dim Rs    as New ADODB.Recordset
Dim strURLInbox as String

strURLInbox = "file:/.//backofficestorage/microsoft.com/MBX/user1/inbox/"
Rec.Open strURLInbox

Dim strView as String
strView = "select " _
 & "  ""DAV:href""" _
 & ", ""DAV:content-class""" _
 & ", ""urn:schemas:httpmail:datereceived""" _
 & ", ""DAV:isfolder""" _
 & ", ""DAV:getcontentlength""" _
 & ", ""urn:schemas:httpmail:from""" _
 & ", ""urn:schemas:httpmail:subject""" _
 & ", ""urn:schemas:mailheader:importance""" _
 & ", ""urn:schemas:httpmail:hasattachment""" _
 & ", ""urn:schemas:httpmail:read""" _
 & " from scope ('shallow traversal of """ _
 & strURLInbox & """') " _
 & " WHERE ""DAV:isfolder"" = false AND ""DAV:ishidden"" = false" _
 & " ORDER BY ""urn:schemas:httpmail:datereceived"" DESC"

Rs.Open strView, Rec.ActiveConnection

If Rs.RecordCount = 0 Then
  ' no items in inbox
Else
  Rs.MoveFirst
  While Not Rs.EOF 
   ' render view data here
     Rs.MoveNext
  Wend
End If