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); }
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); }
public static async void UpdateListOfMessages(ObservableCollection <MessageModel> messages, ImapControl imap) { messages.Clear(); IList <MessageModel> messageInfoCollection = await imap.GetListOfMessages(); for (int i = 0; i < messageInfoCollection.Count; i++) { messages.Add(messageInfoCollection[i]); } }