大家好,我正尝试将 Exchange 2003 邮箱内容列表导出到 CSV 文件。具体来说,我正尝试检索用户邮箱中每封邮件的文件夹路径、主题、大小、接收时间、发送时间(可选)和邮件 ID(也是可选的)。
我使用 Exchange Web Services API 在 Exchange 2007 及更高版本中实现了此功能,但这不适用于 2003。
环境中未启用 WebDAV,我目前正在验证 POP3/IMAP 是否可用。假设不可用,还有其他我遗漏的方法吗?
答案1
您没有提供太多有关您对尝试访问的系统或邮箱的访问权限的信息。如果您是此服务器的 Exchange 管理员,最简单的方法可能是为您添加对相关邮箱的读取权限,并使用 exmerge 将其复制到另一个帐户,或者如果您恰好安装了 Access 作为 Office 套件的一部分,您可以使用 Access 中的“获取外部数据”从 Outlook 中获取电子邮件,并且可以包含日期字段。从 Access 中,您可以非常轻松地将表格转储到 Excel(或 csv)中。
遗憾的是,Exchange Web 服务 API 不适用于 Exchange 2003 或 SBS。
由于您谈论的是 2003 年,因此您可以使用 WMI 或 powershell 来实现您想要的效果。
Brian Desmond 的网站上有一个 WMI 脚本,可以提取此类信息。此脚本会将有关特定服务器或服务器组上每个邮箱的大量有用信息转储到 CSV 文件中,然后您可以将其导入 Excel 并从中创建电子表格。如果我需要进行大量计算或数据挖掘,我通常会使用 DTS(数据转换服务)将数据导入 SQL Server 表。在执行真正需要对大量数据进行索引的任务时,Excel 会变得非常慢。
注意:脚本使用 WMI 获取此信息,因此需要 Exchange 2003。Active Directory 中仅需要 Exchange View Only 级别权限,但您可能需要每个 Exchange 服务器上的本地管理员权限。我没有现成的 Exchange 2003 服务器可供测试,而且他最初编写此脚本时以 Exchange Full Admin 身份运行。因此使用时风险自负!摘自:http://briandesmond.com/blog/script-to-dump-exchange-mailbox-info-to-spreadsheet-csv/
'==========================================================================
' NAME : Exchange Mailbox Stats Dumper
' AUTHOR : Brian Desmond, [email protected]
' DATE : 12/28/2005
' COMMENT: This script requires Exchange 2003. It will dump information
' about each mailbox on the mailbox servers specified
'
' Version Date Author Note
' -----------------------------------------------------------------
' 1.0 28Nov05 Brian Desmond Initial Version
' 1.1 03Sep06 Brian Desmond
' 1.2 13Dec08 Brian Desmond Fixed array sizing bug,
' Added error handling note
' Added TODOs
' Moved configurable items up
'==========================================================================
Option Explicit
' Note this script currently uses On Error Resume Next
' this isn't best practice - in reality this should be tightly
' wrapped around the WMI connection logic in the loop rather
' than up here.
On Error Resume Next
' TODO: Configure this
' This is the total number of servers which you
' will specify for inventory
Const TOTAL_SERVERS = 3
Dim strComputer()
ReDim strComputer(TOTAL_SERVERS)
' TODO: Populate this array
' Enter each server name below as an entry in the array
' starting with zero
strComputer(0) = "xmb01"
strComputer(1) = "xmb02"
strComputer(2) = "xmb03"
'==========================================================================
Dim objWMIService
Dim colItems
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim fil
Set fil = fso.CreateTextFile("mailboxes.txt")
Dim objItem
Dim line
Dim i
' Write a header row to the CSV
fil.WriteLine """Server"",""Storage Group"",""Mail Store"",""Mailbox GUID"",""Display Name"",""LegacyDN"",""Size"",""Item Count"",""Associated Content Count"",""Deleted Message Size"",""Date Absent"",""Storage Limit Level"""
For i = 0 To TOTAL_SERVERS - 1
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer(i) & _
"\ROOT\MicrosoftExchangeV2")
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
For Each objItem in colItems
line = """" & objItem.ServerName & """"
line = line & ","
line = line & """" & objItem.StorageGroupName & """"
line = line & ","
line = line & """" & objItem.StoreName & """"
line = line & ","
line = line & """" & objItem.MailboxGUID & """"
line = line & ","
line = line & """" & objItem.MailboxDisplayName & """"
line = line & ","
line = line & """" & objItem.LegacyDN & """"
line = line & ","
line = line & """" & objItem.Size & """"
line = line & ","
line = line & """" & objItem.TotalItems & """"
line = line & ","
line = line & """" & objItem.AssocContentCount & """"
line = line & ","
line = line & """" & objItem.DeletedMessageSizeExtended & """"
line = line & ","
line = line & """" & objItem.DateDiscoveredAbsentInDS & """"
line = line & ","
line = line & """" & objItem.StorageLimitInfo & """"
fil.WriteLine line
'WScript.Echo line
Next
Next
fil.Close
Set fso = Nothing
Set objWMIService = Nothing