a had successful connection with ExchangeVersion.Exchange2007_SP1, when I changed it on 2010 or latest I get the exception on this row:
service.AutodiscoverUrl(MailboxToAccess, RedirectionUrlValidationCallback); ->System.NullReferenceException: 'Object reference not set to an instance of an object.' I tried with Packages: Exchange.WebServices.Managed.Api v2.2.1.2 and Microsoft.Exchange.WebServices v2.2.0
static void Main(string[] args)
{
String MailboxToAccess = "username@domain";
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false);
service.Credentials = new WebCredential("username@domain", "password");
service.AutodiscoverUrl(MailboxToAccess, RedirectionUrlValidationCallback);
SetStreamingNotifications(service);
}
private static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
bool result = false;
Uri redirectionUri = new Uri(redirectionUrl);
if (redirectionUri.Scheme == "https")
{
result = true;
}
return result;
}
I set the Exchange service URL manually using
I still don't understand why It didn't work for me with