void BtnGetMailClick(object sender, EventArgs e)
        {
            using (var longOperation = new SPLongOperation(Page))
            {
                longOperation.LeadingHTML  = SPSResources.GetResourceString("SPS_FetchMail_Message");
                longOperation.TrailingHTML = SPSResources.GetResourceString("SPS_FetchMail_Message2");
                longOperation.Begin();

                int port;
                Int32.TryParse(_mailPort, out port);

                var fetchMail = new FetchMail(_login,
                                              _password,
                                              _mailServer,
                                              port,
                                              _ssl,
                                              _listGuid);

                fetchMail.GetMessages();

                _error = fetchMail.GetErrorMessage();

                if (!string.IsNullOrEmpty(_error))
                {
                    SPUtility.TransferToErrorPage(_error);
                }
                else
                {
                    longOperation.End(Page.Request.Url.ToString());
                }
            }
        }
        private void GetMailUsingThread()
        {
            int port;

            Int32.TryParse(_mailPort, out port);

            var fetchMail = new FetchMail(_login, _password, _mailServer, port, _ssl, _listGuid);

            _thread = new Thread(fetchMail.ThreadGetMessages);
            _thread.Start();
        }