zoukankan      html  css  js  c++  java
  • 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;
            }
  • 相关阅读:
    货车运输 noip2013day1t3
    热浪 洛谷1339 (对于最短路的复习)
    10.25 考试总结
    2017.10.27
    2017.10.26 noip2013day1
    2017.10.24
    2017.10.23 noip2014day2测试
    bzoj3173 最长上升子序列 题解--Treap+nlogn求LIS
    bzoj1588 营业额统计 题解--Treap
    codevs1068 乌龟棋 题解
  • 原文地址:https://www.cnblogs.com/yuanxiaoping_21cn_com/p/1546081.html
Copyright © 2011-2022 走看看