private void _bRetrieveSpecificMessage_Click(object sender, EventArgs e) { // We create nntp client object. NntpClient nntp = new NntpClient(); try { // We connect to the nntp server. nntp.Connect(_tbNntpServer.Text); // Get a news group on the server NewsGroup group = nntp.SelectGroup(_tbNewsgroup.Text); if (group.ArticleCount > 0) { for (int i = 1; i < group.ArticleCount + 1; i++) { ActiveUp.Net.Mail.Message message = group.RetrieveArticleObject(i); ListViewItem lvi = new ListViewItem(); lvi.Text = i.ToString("0000"); lvi.SubItems.AddRange(new string[] { message.Subject }); lvi.Tag = message; _lvMessages.Items.Add(lvi); this.AddLogEntry(string.Format("{1} Subject: {0}" , message.Subject, i.ToString("0000"))); } } else { this.AddLogEntry("There is no message in the newsgroup."); } } catch (NntpException pexp) { this.AddLogEntry(string.Format("Nntp Error: {0}", pexp.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } finally { if (nntp.IsConnected) { nntp.Disconnect();; } } }
private void _bRetrieveMessageList_Click(object sender, EventArgs e) { // We create nntp client object. NntpClient nntp = new NntpClient(); try { // We connect to the nntp server. nntp.Connect(_tbNntpServer.Text); // Get a news group on the server NewsGroup group = nntp.SelectGroup(_tbNewsgroup.Text); //Retrive the article and display the subject MessageCollection mc = new MessageCollection(); for (int n = 0; n < group.ArticleCount; n++) { ActiveUp.Net.Mail.Message message = group.RetrieveArticleObject(n); mc.Add(message); this.AddLogEntry(string.Format("Subject : {0}", message.Subject)); } //mc will contain the list of messages } catch (NntpException pexp) { this.AddLogEntry(string.Format("Nntp Error: {0}", pexp.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } finally { if (nntp.IsConnected) { nntp.Disconnect();; } } }