コード例 #1
0
        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();;
                }
            }
        }
コード例 #2
0
ファイル: frmNNTP.cs プロジェクト: slavat/MailSystem.NET
 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;
     }
 }
コード例 #3
0
        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();;
                }
            }
        }
コード例 #4
0
        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();;
                }
            }
        }
コード例 #5
0
ファイル: frmNNTP.cs プロジェクト: shekky/MailSystem.NET
        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();
        }
コード例 #6
0
        private void _bNewMessages_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
                // Gets article ids that belong to the "myhost.info" newsgroup and have been added less than one month ago.
                string[] newids = nntp.GetNewArticleIds(_tbNewsgroup.Text, System.DateTime.Now.AddMonths(-1));

                // We get each article as an object.
                foreach (string articleId in newids)
                {
                    ActiveUp.Net.Mail.Message message = nntp.RetrieveArticleObject(articleId);
                    //Display the subject.
                    this.AddLogEntry(string.Format("Subject : {0}", message.Subject));
                }
            }

            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();;
                }
            }
        }
コード例 #7
0
        private void _bRetrieveAllNewsgroup_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 the news group on the server
                NewsGroupCollection groups = nntp.GetNewsGroups();

                foreach (NewsGroup group in groups)
                {
                    this.AddLogEntry(string.Format("Group name : {0}", group.Name));
                }
            }

            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();;
                }
            }
        }
コード例 #8
0
        private void _bPostMessage_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);

                // We create the message to post.
                ActiveUp.Net.Mail.Message msg = new ActiveUp.Net.Mail.Message();
                msg.Subject       = _tbSubject.Text;
                msg.BodyText.Text = _tbBody.Text;
                msg.To.Add(_tbNewsgroup.Text);
                nntp.Post(msg);
            }

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