Exchange2007获取OWA邮箱容量的代码

//一下方法获取到了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;
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值