Click here to Skip to main content
13,300,002 members (62,425 online)
Click here to Skip to main content
Add your own
alternative version


11 bookmarked
Posted 24 Jul 2005

Posting newsgroup messages with NNTP using Indy

Rate this:
Please Sign up or sign in to vote.
In this article, I will demonstrate how to quickly and easily post a message to a newsgroup, including an attachment, using the Indy open source library.


In this article, I will demonstrate how to quickly and easily post a message to a newsgroup, including an attachment, using the Indy open source library.

The Code

using (NNTP xNNTP = new NNTP()) {
  try {
    Message xMsg = new Message(); 
    xMsg.Subject = "Test Message from Indy";
    xMsg.From.Address = "";
    xMsg.Body.Text = "This is a test message.";
    new AttachmentFile(xMsg.MessageParts, 
        System.Environment.CurrentDirectory + @"\..\..\App.ico");
    Console.WriteLine("Message posted");
  } finally {

Running the Demo

The demo simply posts a test message to a test newsgroup on the Microsoft news server. To change it to your news server and newsgroup, simply change the parameters in the demo.


The demo has very little output unless there is an error. To see the results, you should look at the microsoft.test newsgroup using your newsreader. Note that messages may not appear instantly and on the Microsoft server it sometimes takes a few minutes for the message to be visible publicly.

Why Console?

The demo code is a console application. For simple code snippets, I prefer console applications as they are easier to write and to focus on code without the demo being over-shadowed by the interface code. All of the code demonstrated here can of course be used in a WinForms, WebForms, Web services, or other types of applications.

What is Indy?

This demo uses classes from the open source Indy.Sockets library. Indy.Sockets is an open source socket library that supports clients, servers, TCP, UDP, raw sockets, as well as over 100 higher level protocols such as SMTP, POP3, NNTP, HTTP, and many more. Indy.Sockets is available for C#, C++, Delphi, and Visual Basic. NET. Indy runs on Windows, Linux, Microsoft .NET, and Mono.

The downloadable demo includes the Indy assembly so it is ready to run.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Chad Z. Hower, a.k.a. Kudzu
"Programming is an art form that fights back"

Formerly the Regional Developer Adviser (DPE) for Microsoft Middle East and Africa, he was responsible for 85 countries spanning 4 continents and 10 time zones. Now Chad is a Microsoft MVP.

Chad is the chair of several popular open source projects including Indy and Cosmos (C# Open Source Managed Operating System).

Chad is the author of the book Indy in Depth and has contributed to several other books on network communications and general programming.

Chad has lived in Canada, Cyprus, Switzerland, France, Jordan, Russia, Turkey, and the United States. Chad has visited more than 60 countries, visiting most of them several times.

You may also be interested in...


Comments and Discussions

General[Message Deleted] Pin
it.ragester2-Apr-09 22:58
memberit.ragester2-Apr-09 22:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 24 Jul 2005
Article Copyright 2005 by Chad Z. Hower aka Kudzu
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid