Пример #1
0
        private static string TestPost(NntpClient client)
        {
            string messageId = $"cucumber_{Guid.NewGuid()}@hhh.net";

            NntpArticle newArticle = new NntpArticleBuilder()
                .SetMessageId(messageId)
                .SetFrom("Superuser <*****@*****.**>")
                .SetSubject(messageId)
                .AddGroup("alt.test.clienttest")
                .AddGroup("alt.test")
                .AddLine("This is a message with id " + messageId)
                .AddLine("bla bla bla")
                .Build();

            // post
            client.Post(newArticle);

            // read back and show
            ShowArticle(client.Article(messageId).Article);

            return messageId;
        }
Пример #2
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();;
                }
            }
        }