前几天的方案都比较复杂一些,再来一个简单的:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MAPI;
namespace ConsoleApplication3
{
class Program
{
[STAThread]
static void Main()
{
Session session = new Session();
session.Logon(null, null, false, true, 0, true, "exchange2007\nuser1");
InfoStores infoStores = (InfoStores)session.InfoStores;
for (int i = 0; i < (int)infoStores.Count; i++)
{
InfoStore infoStore = (InfoStore)infoStores.get_Item(i + 1);
if (((string)infoStore.Name).IndexOf("Mailbox – ") >-1)
{
Fields fields = (Fields)infoStore.Fields;
Field size = (Field)fields.get_Item(CdoPropTags.CdoPR_MESSAGE_SIZE, System.Reflection.Missing.Value);
Field count = (Field)fields.get_Item(CdoPropTags.CdoPR_CONTENT_COUNT, System.Reflection.Missing.Value);
Console.WriteLine(infoStore.Name + ": " + size.Value + "Bytes, messages:" + count.Value);
}
}
session.Logoff();
Console.ReadLine();
}
}
}
这个方案的问题是需要安装CDO,好在这个东东是微软的,而且很小,安装包才几百K,其实就是把MAPI的一些API包装成COM了,所以.net平台的那些语言都可以调。
发表评论