c# - How to use Microsoft.Exchange.WebServices? -


i try use : microsoft.exchange.webservices.dll use outlook. connection return error

error return line:service.autodiscoverurl("myusernamek@xxxx.com");

the autodiscover service not located. codes:

 using system; using system.collections.generic; using system.linq; using system.text; using system.net.mail; using system.net; using microsoft.exchange.webservices.data; using microsoft.exchange.webservices.autodiscover; using system.net.security; using system.security.cryptography.x509certificates;  namespace test {     class program     {         static void main(string[] args)         {             try             {                 // connect exchange web services user1 @ contoso.com.                 exchangeservice service = new exchangeservice(exchangeversion.exchange2007_sp1);                 service.credentials = new webcredentials("myusernamek@xxxx.com", "mypassword", "xxxx.com");                 service.traceenabled = true;                 service.autodiscoverurl("myusernamek@xxxx.com");                  // create e-mail message, set properties, , send user2@contoso.com, saving copy sent items folder.                  emailmessage message = new emailmessage(service);                 message.subject = "interesting";                 message.body = "the proposition has been considered.";                 message.torecipients.add("recipientname@xxxx.aero");                 message.sendandsavecopy();                  // write confirmation message console window.                 console.writeline("message sent!");                 console.readline();             }             catch (exception ex)             {                 console.writeline("error: " + ex.message);                 console.readline();             }          }     } }

alt text

i know old question, wrestled , similar looking error (including isa server). fixed with:

service.enablescplookup = false; 

this not required when working explicit url, when using autodiscover


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -