Exchange邮件读取
public int GetMailCount1(string username) { string domain = "lzlj"; string email = ""; string pwd = ""; int ecount = 0; if (!string.IsNullOrEmpty(username.Trim()) && !username.ToLower().Contains("system")) //有用户名和密码 { if (!string.IsNullOrEmpty(domain) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(pwd) && !string.IsNullOrEmpty(email)) { try { //ExchangeContext ctx = new ExchangeContext(ExchangeVersion.Exchange2010, "http://mail.lzlj.com", email, new System.Net.NetworkCredential(username, pwd, domain)); ExchangeContext ctx = new ExchangeContext(ExchangeVersion.Exchange2010, "http://mail.lzlj.com", "chenming1@lzlj.com", new System.Net.NetworkCredential("user", "pwd", "lzlj")); ecount = ctx.Inbox.UneadMailCount; } catch (Exception e) { ecount = -1; } } else { } } return ecount; } { if (!string.IsNullOrEmpty(domain) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(pwd) && !string.IsNullOrEmpty(email)) { try { //ExchangeContext ctx = new ExchangeContext(ExchangeVersion.Exchange2010, "http://mail.lzlj.com", email, new System.Net.NetworkCredential(username, pwd, domain)); ExchangeContext ctx = new ExchangeContext(ExchangeVersion.Exchange2010, "http://mail.lzlj.com", "chenming1@lzlj.com", new System.Net.NetworkCredential("user", "pwd", "lzlj")); ecount = ctx.Inbox.UneadMailCount; } catch (Exception e) { ecount = -1; } } else { } } return ecount; }
用户评论
感谢分享,很实用
不错,帮别人下载的