static private EWSConnection ConnectToEWS()

in Mail2Bug/Email/EWS/EWSConnectionManger.cs [82:109]


        static private EWSConnection ConnectToEWS(Credentials credentials, bool useConversationGuidOnly)
        {
            Logger.DebugFormat("Initializing FolderMailboxManager for email adderss {0}", credentials.EmailAddress);
            var exchangeService = new ExchangeService(ExchangeVersion.Exchange2010_SP1)
            {
                Credentials = new WebCredentials(credentials.UserName, credentials.Password),
                Timeout = 60000
            };

            exchangeService.AutodiscoverUrl(
                credentials.EmailAddress,
                x =>
                {
                    Logger.DebugFormat("Following redirection for EWS autodiscover: {0}", x);
                    return true;
                }
                );

            Logger.DebugFormat("Service URL: {0}", exchangeService.Url);

            return new EWSConnection()
            {
                Service = exchangeService,
                Router =
                    new RecipientsMailboxManagerRouter(
                        new EWSMailFolder(Folder.Bind(exchangeService, WellKnownFolderName.Inbox), useConversationGuidOnly))
            };
        }