retrieving Mailbox size...

retrieving Mailbox size...

Post by Bobby Boy » Fri, 11 Jul 2003 03:35:21



Hello,

I am looking for a way to programmatically retrieve the
size of the Mailbox.
Please lead me into the right direction...

Thank you,
Bobby

 
 
 

retrieving Mailbox size...

Post by Michael B. Smit » Sat, 19 Jul 2003 01:48:13


Function GetMailboxSize (strMailBoxName, strDomainName)
    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
    Dim i

    On Error Resume Next

    set Rs = Wscript.CreateObject ("ADODB.Recordset")
    set Rec = Wscript.CreateObject ("ADODB.Record")

    mailboxSZ = 0

    sUsername = strMailBoxName

    sURL = "file://./backofficestorage/" & strDomainName & "/MBX/" &
sUserName
    'wscript.echo sURL

    Rec.Open sURL
    If Err.Number <> 0 Then
        strErr = "Could not open: " & sURL & " (" & err.Description & ")"
        GetMailboxSize = -1
        Exit Function
    End If

    sSQL = "Select"
    sSQL = sSQL & " ""http://schemas.microsoft.com" & _
                  "/exchange/foldersize"" "
    sSQL = sSQL & ", ""DAV:displayname"" "
    sSQL = sSQL & " from scope ('deep 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
        'Wscript.echo Rs.Fields("DAV:displayname").Value & " " & _
        '
Rs.Fields("http://schemas.microsoft.com/exchange/foldersize").Value
        mailboxSZ = mailboxSZ + _

Rs.Fields("http://schemas.microsoft.com/exchange/foldersize").Value
        Rs.MoveNext
    Wend
    'Wscript.echo "Mailbox: " & strMailBoxName & " size: " & mailboxSZ & "
bytes"
    GetMailboxSize = mailboxSZ
    Rs.Close
    Rec.Close

    set Rs = Nothing
    set Rec = Nothing
End Function


Quote:> Hello,

> I am looking for a way to programmatically retrieve the
> size of the Mailbox.
> Please lead me into the right direction...

> Thank you,
> Bobby