Click here to Skip to main content
15,867,686 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.6K   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

 
QuestionYenc? Pin
Carl Mercier22-Mar-04 4:10
Carl Mercier22-Mar-04 4:10 
AnswerRe: Yenc? Pin
HKcow22-Mar-04 14:34
HKcow22-Mar-04 14:34 
GeneralRe: Yenc? Pin
casperOne25-Mar-04 2:26
casperOne25-Mar-04 2:26 
GeneralRe: Yenc? Pin
Anonymous25-Mar-04 14:07
Anonymous25-Mar-04 14:07 
GeneralRe: Yenc? Pin
HKcow25-Mar-04 14:13
HKcow25-Mar-04 14:13 
GeneralRe: Yenc? Pin
casperOne25-Mar-04 16:32
casperOne25-Mar-04 16:32 
GeneralRe: Yenc? Pin
HKcow25-Mar-04 21:33
HKcow25-Mar-04 21:33 
GeneralRe: Yenc? Pin
Carl Mercier25-Mar-04 4:17
Carl Mercier25-Mar-04 4:17 
Hi,

I have found something for you Smile | :)

http://www.fesersoft.com/Products/default.asp

Code for yEnc! No excuse for now implementing it now Wink | ;)

Your NNTP library is great, that you!

Carl

GeneralRe: Yenc? Pin
Carl Mercier25-Mar-04 4:20
Carl Mercier25-Mar-04 4:20 
GeneralRe: Yenc? Pin
HKcow25-Mar-04 14:11
HKcow25-Mar-04 14:11 
GeneralRe: Yenc? Pin
Carl Mercier25-Mar-04 14:53
Carl Mercier25-Mar-04 14:53 

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.