免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1894 | 回复: 0
打印 上一主题 下一主题

[Mail] Exchange2007获取OWA邮箱容量的代码 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-01-19 01:45 |只看该作者 |倒序浏览
//一下方法获取到了Response对象后获取他的html内容 就是:<div id=mbUsg>15224</div><div id=dspMbUsg>14.87 KB</div>
        private string GetMailboxUsageString() {
            string url = Config.ExchangeServerPath.Replace("/exchange/", "/owa/") + "ev.owa?oeh=1&ns=Tree&ev=GetMailboxUsage";
            WebResponse ret = HttpCallGetMailboxUsage(url);
            Stream stream = ret.GetResponseStream();
            StreamReader sr = new StreamReader(stream, Encoding.GetEncoding("UTF-8"));
            string htmlstr = sr.ReadToEnd();
            return htmlstr;
        }

        /// <summary>
        /// 获取用户已经使用的容量
        /// </summary>
        /// <returns>返回已使用容量的byte数 /1024 单位为kb  再/1024 单位为 MB</returns>
        public int GetMailboxUsage() {
            string usageString = GetMailboxUsageString();
            Match mc = Regex.Match(usageString, @"^<div id=mbUsg>([\d]+)</div><div id=dspMbUsg>([\d|\w|\W]+)</div>$");
            return Convert.ToInt32(mc.Groups[1].Value);
        }

        /// <summary>
        /// 获取用户已经使用的容量
        /// </summary>
        /// <returns>返回已使用容量的原始文本</returns>
        public string GetMailboxUsageSourceString() {
            string usageString = GetMailboxUsageString();
            Match mc = Regex.Match(usageString, @"^<div id=mbUsg>([\d]+)</div><div id=dspMbUsg>([\d|\w|\W]+)</div>$");
            return mc.Groups[0].Value;
        }

        /// <summary>
        /// 获取用户已经使用的容量
        /// </summary>
        /// <returns>返回已使用容量的显示文本</returns>
        public string GetMailboxUsageDisplayString() {
            string usageString = GetMailboxUsageString();
            Match mc = Regex.Match(usageString, @"^<div id=mbUsg>([\d]+)</div><div id=dspMbUsg>([\d|\w|\W]+)</div>$");
            return mc.Groups[2].Value;
        }
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP