C# EWS reduce mailbox connection time RRS feed

  • Question

  • I have a program for reading incoming mail outlook (exchange server 2016)
    the program runs in the task scheduler windows using account "system" but at the connection step the program waits a few minutes.
    if the program starts using a domain account, then the connection is made without expectations.
    I do not want to change the settings in the task scheduler windows.
    I think that the problem is in the connection timeout, how to reduce  connection time and start searching for the mailbox after domain authorization?

    I use this when connecting :

    string url = "Url";
    string UserLogin = "UserLogin";
    string UserPassword = "UserPassword";
    string UserDomain = "UserDomain";
    string UserEmail = "UserEmail";
    ExchangeService ews = new ExchangeService();
    UserPrincipal userP = UserPrincipal.FindByIdentity(new PrincipalContext(ContextType.Domain, UserDomain, UserLogin, UserPassword), Environment.UserName);
    ews.Credentials = new WebCredentials(UserLogin, UserPassword, UserDomain);
    Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverRedirectionUrlValidationCallback RedirectionUrlValidationCallback = null;
    ews.AutodiscoverUrl(UserEmail, RedirectionUrlValidationCallback);
    Folder inbox = Folder.Bind(ews, WellKnownFolderName.Inbox);
    PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Body);

    Sunday, December 8, 2019 1:57 PM

All replies

  • Hi Aleks Roth,
    I viewed your description which seems to be more relevant to EWS.
    So I suggest you go to the EWS forum to ask questions, and you will get more professional responses in there.
    Thank you for understanding.
    Best Regards,
    Daniel Zhang

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 9, 2019 9:44 AM