解惑

解己之惑,解人之惑

日:2009年8月25日

开始习惯MSDN格式的API文档了

最开始很不习惯MSDN格式的api文档,感觉很分散,原理性介绍、快速入门、API的说明以及常量定义都不知道怎么弄的。
经过对CDO的文档的摸索,发现这些东西都是存在的,只是和JAVA的那些习惯不一样,java的组件的文档一般比较全面,而且把这些东西组织得很好,开始就是quick start,然后是developement guide,最后就是API reference,链接也做得比较好。虽然MSDN的文档不缺少这些内容,在内容之间的引用做得似乎弱一些。

从CDO得到Mailbox的大小

前几天的方案都比较复杂一些,再来一个简单的:
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平台的那些语言都可以调。

© 2025 解惑

本主题由Anders Noren提供向上 ↑