// 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(); ;
}
}