c# - Sending the mail via Exchange service -


am trying send mail via exchange server without opening outlook, have used code below. following below code send mail directly exchange service, receiving error autodiscovery url can please me out here.

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using microsoft.exchange.webservices.data;  namespace serivcemessgae {     class program     {         static void main(string[] args)         {             exchangeservice service = new exchangeservice(exchangeversion.exchange2013_sp1);              service.credentials = new webcredentials("karan.kotabagi@***.com", "***");              service.traceenabled = true;             service.traceflags = traceflags.all;              service.autodiscoverurl("karan.kotabagi@***.com", redirectionurlvalidationcallback);              emailmessage email = new emailmessage(service);              email.torecipients.add("karan.kotabagi@***.com");              email.subject = "helloworld";             email.body = new messagebody("this first email i've sent using ews managed api");              email.send();         }          private static bool redirectionurlvalidationcallback(string redirectionurl)         {             // default validation callback reject url.             bool result = false;              uri redirectionuri = new uri(redirectionurl);              // validate contents of redirection url. in simple validation             // callback, redirection url considered valid if using https             // encrypt authentication credentials.              if (redirectionuri.scheme == "https")             {                 result = true;             }             return result;           }     } } 


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -