本文描述如何使用 Microsoft Visual C、Microsoft Visual C++、Microsoft Visual Basic 和 Microsoft Visual Basic Scripting Edition (VBScript) 在运行 Microsoft Exchange 的服务器上以编程方式检索有关邮箱大小的信息。
扩展 MAPI 方法
可用的编程语言:Visual C 和 Visual C++
Exchange Server 版本:Exchange Server 5.5、Exchange 2000 和 Exchange 2003
扩展 MAPI 提供了
IExchangeManageStore 接口以从 Exchange 信息存储区获得管理信息。此接口提供了
GetMailboxTable 函数,该函数返回包含有关特定服务器上邮箱信息的
IMAPITable 接口。请注意此函数要求具有对运行 Exchange Server 的服务器的管理权限。
此表包含的列提供了有关每个邮箱大小的信息。
PR_MESSAGE_SIZE 属性包含邮箱的大小(以字节为单位)。
有关其他信息,请访问下面的 Microsoft Developer Network (MSDN) 网站:
IExchangeManageStore::GetMailboxTable
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/exchserv/html/intrface_24it.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/exchserv/html/intrface_24it.asp)
有关其他信息,请单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
200160 (http://support.microsoft.com/kb/200160/) 如何使用 GetMailboxTable 循环完 Exchange 上的邮箱
CDO 1.21 方法
可用的编程语言:VBScript、Visual Basic、Visual C 和 Visual C++
Exchange Server 版本:Exchange Server 5.5、Exchange 2000 和 Exchange 2003
可以使用协作数据对象 (CDO) 1.21 通过 CDO
InfoStore 对象,检查用户邮箱存储上的相同属性。在此方法中,应用程序必须先登录到邮箱,然后才可以检查此属性。这意味着应用程序必须能够访问服务器上的所有邮箱。此方法还要求生成服务器上邮箱的列表,并在代码中循环完这些邮箱。
下面的示例是一个简单的 VBScript 代码示例,可以检查邮箱上的此属性。要使用此示例,请将下面的代码粘贴到一个新的文本文件,然后将此文件命名为 Mailboxsize.vbs:
'This script logs on to a server that is running Exchange Server and'displays the current number of bytes that are used in the user's'mailbox and the number of messages.' USAGE: cscript MailboxSize.vbs SERVERNAME MAILBOXNAME' This requires that CDO 1.21 is installed on the computer.' This script is provided AS IS. It is intended as a SAMPLE only.' Microsoft offers no warranty or support for this script.' Use at your own risk.' Get command line arguments.Dim obArgsDim cArgsSet obArgs = WScript.ArgumentscArgs = obArgs.CountMainSub Main() Dim oSession Dim oInfoStores Dim oInfoStore Dim StorageUsed Dim NumMessages Dim strProfileInfo Dim sMsg On Error Resume Next If cArgs <> 2 Then WScript.Echo "Usage: cscript MailboxSize.vbs SERVERNAME MAILBOXNAME" Exit Sub End If 'Create Session object. Set oSession = CreateObject("MAPI.Session") if Err.Number <> 0 Then sMsg = "Error creating MAPI.Session." sMsg = sMsg %26amp; "Make sure CDO 1.21 is installed. " sMsg = sMsg %26amp; Err.Number %26amp; " " %26amp; Err.Description WScript.Echo sMsg Exit Sub End If strProfileInfo = obArgs.Item(0) %26amp; vbLf %26amp; obArgs.Item(1) 'Log on. oSession.Logon , , False, True, , True, strProfileInfo if Err.Number <> 0 Then sMsg = "Error logging on: " sMsg = sMsg %26amp; Err.Number %26amp; " " %26amp; Err.Description WScript.Echo sMsg WScript.Echo "Server: " %26amp; obArgs.Item(0) WScript.Echo "Mailbox: " %26amp; obArgs.Item(1) Set oSession = Nothing Exit Sub End If 'Grab the information stores. Set oInfoStores = oSession.InfoStores if Err.Number
如果您对本文有任何疑问或者建议,请到讨论区发表您的意见:
>>
论坛入口 <<
上一篇:单击“新邮件”图标时OWA启动Windows安装程序 下一篇:将移动设备与Exchange Server 2003同步时收到 HTTP_500 错误信息
【文章评论】
【收藏本文】
【推荐好友】
【打印本文】
【我要投稿】 【论坛讨论】