参考地址
https://stackoverflow.com/questions/16099853/exchange-and-powershell
https://docs.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.exchangeservice?view=exchange-ews-api
https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/ff326159(v=exchg.140)
原理就是调用服务器上的Exchaange Management Shell
核心代码展示
string schemaUri = "http://schemas.microsoft.com/powershell/Microsoft.Exchange"; string exPWD = ConfigurationManager.AppSettings["exPWD"].ToString(); exPWD =Common.Utility.AESEncrypt.Decrypt(exPWD); string exUser = ConfigurationManager.AppSettings["exUser"].ToString(); SecureString ser = ConvertToSecureString(exPWD); PSCredential credential_ = new PSCredential("centhome\\"+ exUser, ser); SearchMailModel smM = new SearchMailModel(); smM.From = from; smM.Subject = subject; smM.Targetmail = targetmail; smM.received = received; Collection<PSObject> psResult = GetUsersUsingBasicAuth("https://mbx011.centhome.com/powershell", schemaUri,credential_, smM);
请发表评论