當(dāng)前位置:首頁 > IT技術(shù) > Windows編程 > 正文

C# 操作Exchange 的powershell以實現(xiàn)郵件撤回
2021-09-24 14:47:37

參考地址

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)

原理就是調(diào)用服務(wù)器上的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);

?

本文摘自 :https://www.cnblogs.com/

開通會員,享受整站包年服務(wù)立即開通 >