Click here to Skip to main content
15,885,782 members
Articles / Programming Languages / C#
Article

NNTP library that supports post retrieval with attachments and a lot more

Rate me:
Please Sign up or sign in to vote.
4.25/5 (13 votes)
24 Mar 20041 min read 227.9K   520   42   41
NNTP library for .NET

Image 1

Introduction

I have built this library because I found that there is lack of support for NNTP. I wanted a library supporting Multilanguage posts with attachments. That required MIME handling, Base64, UUEncode, Quoted-Printable etc. I also wanted a library with Authentication support too.

Using the code

Classes can be classified as below.

  • BS: NntpConnection
  • VO: Article, ArticleBody, ArticleHeader, Attachment, MIMEPart, Newsgroup
  • Util: NntpUtil
  • Exp: NntpException

Using the library is simple, and it is done mainly by manipulating the NntpConnection class.

Connect to a specified news server and list all the newsgroups:

C#
NntpConnection con = new NntpConnection();
con.ConnectServer(serverName, 119);
ArrayList list = con.GetGroupList();
foreach ( Newsgroup ng in list )
    Console.WriteLine(ng.Group);

Subscribe to a group and list out all the articles:

C#
Newsgroup ng = con.ConnectGroup(groupName);
ArrayList list = con.GetArticleList(ng.Low, ng.High);
foreach( Article article in list )
    Console.WriteLine(article.Header.Subject);

Retrieve an article, examine the text content and save the attachment:

C#
// msgId can be a string or an integer
Article a = con.GetArticle(msgId);
Console.WriteLine(a.Body.Text);
foreach ( Attachment at in a.Body.Attachments )
{
    at.SaveAs(@"C:\Temp\" + at.Filename, true);
}

If you want to provide an identity:

C#
NntpConnection con = new NntpConnection();
con.ConnectServer(serverName, 119);
// Identity will be store and will be sent automatically upon the server request
con.ProvideIdentity(username, password);
// You can force the identity to be sent immediately, 
// however some servers do not support this
con.SendIdentity();

This is a brief description only and my library has many more features. I will review this article if I have time.

More Information

Articles are decoded by self-built library, where it is still far away from the internet standard. However, it should be able to decode over 95% of the posts in the internet. These codes are still under development and will be updated soon.

History

  • Beta 0.1 2004/03/17
  • Beta 0.2 2004/03/23
    • Enhanced MIME support by optimizing internal implementation.
    • Restructured some classes.
    • New authentication methods.

License

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


Written By
Hong Kong Hong Kong
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionError: value to small or large for Int32 Pin
Russell Mangel3-Dec-18 2:41
Russell Mangel3-Dec-18 2:41 
QuestionDateTime Parsing errors Pin
Russell Mangel3-Dec-18 2:18
Russell Mangel3-Dec-18 2:18 
Questionany updates? like yEnc for example? Pin
ringdrossel12-Sep-09 4:49
ringdrossel12-Sep-09 4:49 
QuestionDateTimeFormat errors (It doesn't like the DateTime Object) Pin
undeclared9-Jul-07 0:50
undeclared9-Jul-07 0:50 
AnswerRe: DateTimeFormat errors (It doesn't like the DateTime Object) Pin
undeclared9-Jul-07 1:36
undeclared9-Jul-07 1:36 
Generalmultiple part attatchements Pin
ThisBytes517-Mar-07 8:57
ThisBytes517-Mar-07 8:57 
QuestionPost message Pin
Brennon Williams3-Aug-06 15:59
Brennon Williams3-Aug-06 15:59 
AnswerRe: Post message Pin
eric.nadeau5-Jan-07 8:43
eric.nadeau5-Jan-07 8:43 
GeneralRe: Post message Pin
eric.nadeau9-Jan-07 3:44
eric.nadeau9-Jan-07 3:44 
GeneralRe: Post message [modified] Pin
eric.nadeau4-Apr-07 4:22
eric.nadeau4-Apr-07 4:22 
GeneralGood Job~ Pin
dvdv35iVE8-Jan-06 8:47
dvdv35iVE8-Jan-06 8:47 
QuestionArrange Headers ? Pin
nihonsx58-Dec-05 16:56
nihonsx58-Dec-05 16:56 
GeneralImage Attachments Pin
DidierSanDiego10-Aug-05 14:12
DidierSanDiego10-Aug-05 14:12 
GeneralRe: Image Attachments Pin
DidierSanDiego10-Aug-05 15:07
DidierSanDiego10-Aug-05 15:07 
QuestionConfused about onRequest Pin
MKlucher5-Aug-05 12:18
MKlucher5-Aug-05 12:18 
GeneralExcellent Job! just one comment :) Pin
Steven Burns28-Aug-04 8:58
Steven Burns28-Aug-04 8:58 
Generalgood job Pin
bouli11-May-04 4:23
bouli11-May-04 4:23 
GeneralRe: good job Pin
asabit26-Dec-04 4:23
asabit26-Dec-04 4:23 
GeneralSample Project Pin
mdande21-Apr-04 19:43
mdande21-Apr-04 19:43 
QuestionAm I missing Something? Pin
Russell Mangel27-Mar-04 1:34
Russell Mangel27-Mar-04 1:34 
AnswerRe: Am I missing Something? Pin
HKcow27-Mar-04 3:48
HKcow27-Mar-04 3:48 
AnswerRe: Am I missing Something? Pin
bouli11-May-04 4:02
bouli11-May-04 4:02 
GeneralWell Done Pin
JaseNet26-Mar-04 18:13
JaseNet26-Mar-04 18:13 
GeneralRe: Well Done Pin
JaseNet26-Mar-04 19:22
JaseNet26-Mar-04 19:22 
GeneralRe: Well Done Pin
HKcow26-Mar-04 20:07
HKcow26-Mar-04 20:07 

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.