Microsoft KB Archive/255992

= How to Determine the Size of an Exchange 2000 Server Mailbox with ADO =

Article ID: 255992

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft ActiveX Data Objects 2.5

-



This article was previously published under Q255992



SUMMARY
You can use ActiveX Data Objects (ADO) to determine the size of a user's mailbox. This artlcle contains sample code that demonstrates how to do this.



MORE INFORMATION
The following function determines the size of a mailbox by using ADO: Private Sub Form_Load Dim strMailBoxName As String strMailBoxName = "MyAlias" Debug.Print "Mailbox Size: " & dblGetMailboxSize(strMailBoxName) End Sub

Private Function dblGetMailboxSize(strMailBoxName As String) As Double 'Requires reference to: 'Active DS Type Library (activeds.tlb) 'Microsoft ActiveX Data Objects 2.5 Library (msado15.dll) Dim Info As New ADSystemInfo Dim sDomainName As String Dim sUserName As String Dim mailboxSZ As Double Dim sURL As String Dim sSQL As String Dim Rs As New ADODB.Recordset Dim Rec As New ADODB.Record mailboxSZ = 0 sDomainName = Info.DomainDNSName sUserName = strMailBoxName sURL = "file://./backofficestorage/" & sDomainName & _ "/MBX/" & sUserName Rec.Open sURL sSQL = "Select" sSQL = sSQL & " ""http://schemas.microsoft.com" & _ "/exchange/foldersize"" " sSQL = sSQL & ", ""DAV:displayname"" " sSQL = sSQL & " from scope ('shallow traversal of " & Chr(34)   sSQL = sSQL & sURL & Chr(34) & "')" sSQL = sSQL & "Where ""DAV:isfolder""=true" Rs.Open sSQL, Rec.ActiveConnection If Not Rs.EOF Then Rs.MoveFirst End If   While Not Rs.EOF 'Uncomment the following lines if you would like to 'see the size of each folder 'Debug.Print Rs.Fields("DAV:displayname").Value 'Debug.Print Rs.Fields("http://schemas.microsoft.com" & _       '                     "/exchange/foldersize").Value mailboxSZ = mailboxSZ + _ Rs.Fields("http://schemas.microsoft.com" & _                   "/exchange/foldersize").Value Rs.MoveNext Wend dblGetMailboxSize = mailboxSZ Rs.Close Rec.Close End Function

Additional query words: ADO

Keywords: kbhowto kbprogramming KB255992

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.