private void _bCountMessage_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); // Display the message count. string.Format("Message Count: {0}", group.ArticleCount.ToString()); } 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 btnRetreive_Click(object sender, EventArgs e) { //Retrieve newsgroup entries btnRetreive.Enabled = false; try { NntpClient nntp = new NntpClient(); nntp.Connect(txtServer.Text); NewsGroup group = nntp.SelectGroup(txtnews.Text); //Display the listView1 of entries received for (int i = 0; i < 10; i++) { try { listView1.Items.Add(new ListViewItem(group.RetrieveHeaderObject().Subject)); group.Next(); } catch { } } nntp.Disconnect(); } finally { btnRetreive.Enabled = true; } }
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();; } } }
private void btnRetreive_Click(object sender, EventArgs e) { NntpClient nntp = new NntpClient(); nntp.Connect(txtServer.Text); NewsGroup group = nntp.SelectGroup(txtnews.Text); for (int i = 0; i < 10; i++) { try { listView1.Items.Add(new ListViewItem(group.RetrieveHeaderObject().Subject)); group.Next(); } catch { } } nntp.Disconnect(); }