コード例 #1
0
        private async void OnConnectCommandExecutedAsync()
        {
            if (IsBusy)
            {
                return;
            }
            if (!Validate())
            {
                return;
            }

            if (ServerType == Constants.ServerTypes.IMAP)
            {
                emailService = new ImapEmailService(Server, Username, Password, Encryption, Port);
            }
            else if (ServerType == Constants.ServerTypes.POP3)
            {
                emailService = new Pop3EmailService(Server, Username, Password, Encryption, Port);
            }
            else
            {
                ErrorMessage = "Selected server type is not supported.";
                return;
            }
            emailService.ItemsDownloaded += OnEmailService_ItemsDownloaded;
            IsBusy = true;
            try
            {
                MessageBody = null;
                EmailItems.Clear();
                await emailService.BeginDownloadInboxAsync(cts.Token);
            }
            catch (Exception ex)
            {
                RenderErrorMessageToUI(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }