예제 #1
0
        public bool CreateSmtpWindowAndConnectToServer(string userName, string password)
        {
            _smtpWindow       = new SmtpWindow();
            _user             = new LoginInfo();
            _user.ImapAddress = "imap.gmail.com";
            _user.Username    = userName;
            _user.Password    = password;
            Login             = userName;
            Password          = password;
            _imap             = new ImapControl(993);
            try
            {
                if (!_imap.Connect(_user))
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error.Connect to server");
            }
            ViewModel.ViewModel.UpdateListOfMessages(Messages, _imap);
            ShowMessagesDataGrid.ItemsSource = Messages.OrderByDescending(m => m.Unread);
            SetCheckedForUnreadMessage();

            int num = 0;

            _timer = new Timer(SendToServerCommands, new object(), 20000, 20000);
            return(true);
        }
예제 #2
0
        ObservableCollection <MessageModel> UpdateMessages()
        {
            var messages = new ObservableCollection <MessageModel>();

            _imap.Logout();
            _imap.Connect(_user);
//            _imap.GetUids();
            var listOfNewMessages = _imap.UpdateListMessages(Messages.Count.ToString());

            foreach (var message in listOfNewMessages)
            {
                messages.Add(message);
            }

            return(messages);
        }
예제 #3
0
        public static bool ConnectToServer(ref ImapControl imap, string userName, string password)
        {
            LoginInfo user = new LoginInfo();

            user.ImapAddress = "imap.gmail.com";
            user.Username    = userName;
            user.Password    = password;
            imap             = new ImapControl(993);
            try
            {
                return(imap.Connect(user));
            }
            catch (Exception)
            {
                MessageBox.Show("Error.Connect to server");
            }

            return(false);
        }