简体   繁体   中英

Read email form Exchange using C# EWS

im trying to read email from exchange server using the below script :

 XmlReaderSettings xrs = new XmlReaderSettings();
            xrs.ProhibitDtd = false;
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CertificateValidationCallBack);
            service.Credentials = new WebCredentials("user", "password" , "domain");
            service.UseDefaultCredentials = true;
            service.TraceEnabled = true;
            service.TraceFlags = TraceFlags.All;


            service.Url = new Uri("https://IP/");
            Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
            Label1.Text = inbox.DisplayName.ToString();`

but im getting this error :

DTD is prohibited in this XML document.

i try this solution :

XmlReaderSettings xrs = new XmlReaderSettings(); xrs.ProhibitDtd = false; but error stil there .

XmlReaderSettings xrs = new XmlReaderSettings()
xrs.DtdProcessing = DtdProcessing.Parse;

Documented at: https://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.dtdprocessing(v=vs.110).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM