在WebPart中获取Office 365中的未读邮件数

// Create the web request  
HttpWebRequest request
  = WebRequest.Create("https://outlook.office365.com/api/v1.0/me/messages/$count?$filter=IsRead%20eq%20false") as HttpWebRequest;

// Add authentication to request  
request.Credentials = new NetworkCredential("username", "password");

// Get response  
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
  // Get the response stream  
    StreamReader reader = new StreamReader(response.GetResponseStream());

    // 显示在前台控件中  
    unreadCount.Text = reader.ReadToEnd();
}  

 

posted @ 2016-08-10 14:30  乘奔御风  阅读(260)  评论(0编辑  收藏  举报