Click here to Skip to main content
Licence 
First Posted 21 Mar 2004
Views 78,563
Bookmarked 41 times

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

By | 24 Mar 2004 | Article
NNTP library for .NET

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:

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:

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:

// 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:

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

About the Author

HKcow



Hong Kong Hong Kong

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionany updates? like yEnc for example? Pinmemberringdrossel4:49 12 Sep '09  
QuestionDateTimeFormat errors (It doesn't like the DateTime Object) Pinmemberundeclared0:50 9 Jul '07  
AnswerRe: DateTimeFormat errors (It doesn't like the DateTime Object) Pinmemberundeclared1:36 9 Jul '07  
Generalmultiple part attatchements PinmemberThisBytes58:57 17 Mar '07  
QuestionPost message PinmemberThe Will15:59 3 Aug '06  
AnswerRe: Post message Pinmembereric.nadeau8:43 5 Jan '07  
GeneralRe: Post message Pinmembereric.nadeau3:44 9 Jan '07  
GeneralRe: Post message [modified] Pinmembereric.nadeau4:22 4 Apr '07  
GeneralGood Job~ PinmemberVB.NET / ASP.NET Beginner8:47 8 Jan '06  
QuestionArrange Headers ? Pinmembernihonsx516:56 8 Dec '05  
GeneralImage Attachments PinsussDude9021014:12 10 Aug '05  
GeneralRe: Image Attachments PinsussDuder9021015:07 10 Aug '05  
QuestionConfused about onRequest PinmemberKluch12:18 5 Aug '05  
GeneralExcellent Job! just one comment :) PinmemberSteven Burns8:58 28 Aug '04  
Generalgood job Pinmemberbouli4:23 11 May '04  
GeneralRe: good job Pinmemberasabit4:23 26 Dec '04  
GeneralSample Project Pinmembermdande19:43 21 Apr '04  
QuestionAm I missing Something? PinmemberRussell Mangel1:34 27 Mar '04  
AnswerRe: Am I missing Something? PinmemberHKcow3:48 27 Mar '04  
AnswerRe: Am I missing Something? Pinmemberbouli4:02 11 May '04  
GeneralWell Done PinsussJaseNet18:13 26 Mar '04  
GeneralRe: Well Done PinmemberJaseNet19:22 26 Mar '04  
GeneralRe: Well Done PinmemberHKcow20:07 26 Mar '04  
GeneralKnown Issue PinmemberHKcow13:58 26 Mar '04  
QuestionConsidered OO design? Pinmemberzucchini10:58 23 Mar '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web02 | 2.5.120517.1 | Last Updated 25 Mar 2004
Article Copyright 2004 by HKcow
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid