private void downloadReplaysButton_Click(object sender, RoutedEventArgs e) { string smtpUsername = smtpUsernameTextBox.Text; string smtpPassword = smtpPasswordTextBox.Text; string pop3Url = smtpUrlTextBox.Text; smtpUsername = "******"; smtpPassword = "******"; pop3Url = "pop3.live.com"; if (string.IsNullOrEmpty(smtpUsername) || string.IsNullOrEmpty(smtpPassword) || string.IsNullOrEmpty(pop3Url)) return; POPClient client = new POPClient(); client.Connect(pop3Url, 995, true); client.Authenticate(smtpUsername, smtpPassword); if (!client.Connected) return; int totalEmails = client.GetMessageCount(); for (int i = 83; i < totalEmails; i++) { OpenPOP.MIME.Header.MessageHeader header = client.GetMessageHeaders(i); if (header.Subject.IndexOf("SC2Replay", StringComparison.InvariantCultureIgnoreCase) == -1) continue; OpenPOP.MIME.Message message = client.GetMessage(i); if (message == null) continue; if (message.Attachments.Count != 1) continue; OpenPOP.MIME.Attachment attachment = message.Attachments[0]; if (attachment.IsMIMEMailFile()) continue; if (attachment.Headers.ContentType.Name == null) continue; if (attachment.Headers.ContentType.Name.ToLower() != "sc2replay") continue; attachment.SaveToFile(@"C:\waka.sc2replay"); } client.Disconnect(); }