Santry Technology Solutions, Content Management, DotNetNuke, SharePoint Consulting
Register | Login
Wednesday, January 07, 2009

Sections
  
About Us
  
Partners
Downloads
  
 WWWCoder.com Resource Directory

Exposing NNTP in Your Web
9/13/2000 12:51:50 PM

This article is provided to give you some ideas on how you can expose NNTP functionality into your Web site using ASP and the File System Object.

NNTP is similar to the SMTP service provided by IIS, in that it consists of a directory structure and text files that adhere to protocol standards. Because of this standard, you can expose NNTP functionality in your Web site or other application by using the FileSystem Object that is included with the Windows 2000 operating system.
For example, a newsgroup called support is located on the server1 NNTP server. This newsgroup was previously configured in IIS. There are two messages contained in the support newsgroup on the news server. The file structure on the server machine contains two text files located in the c:\inetpub\nntpfile\root\support

As demonstrated in the example on SMTP (Sending Mail) you can easily manipulate files contained in a directory on the IIS machine. In the SMTP example we created a file, in this example we will list the contents of the NNTP directory and open a file and view the contents in a Web browser:

<html>
<head>
<title>NNTP Reader</title>
</head>
<body>
<%
CONST PATH_INFO = "c:\inetpub\nntpfile\root\support\" Sub ShowFileList Dim i, FileType, fs, f, fc Set fs = Server.CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(PATH_INFO) Set fc = f.SubFolders Set fc = f.Files For Each f1 in fc For i = 1 To 4 If i = 1 Then Response.Write "&nbsp;&nbsp;<a “ & _ “href=nntp.asp?action=open&file=" & _ PATH_INFO & f1.name & ">" & f1.name & "</a><br>" End If Next Next Set fs = Nothing End Sub
Function OpenTextFile(PathInfo) Dim fs, InStream Set fs = Server.CreateObject("Scripting.FileSystemObject") Set InStream = fs.OpenTextFile (PathInfo, 1, False, False) OpenTextFile = Instream.ReadALL InStream.Close Set InStream = Nothing Set fs = Nothing End Function
If Request("Action") = "open" Then Response.Write "<pre>" & OpenTextFile(Request("file")) & "</pre>" Else ShowFileList End If
%>
</body> </html>

In the preceding block of code, the first thing we do is the list the files that are contained in the NNTP directory. The user can then click on the file name to view its contents. You could further extend this script by opening the file and pulling out the NNTP header for the subject and displaying that to the user instead of the filename, and then parse the headers when viewing the message to present a better format to the user.

Extending upon this method can allow you to provide an integrated messaging application that is viewable in a Web browser and in a newsgroup reader like Outlook Express. You can also extend upon this by taking advantage of the search capabilities of Indexing services to provide a search mechanism for the Web application.

By: Patrick Santry, Microsoft MVP (ASP/ASP.NET), developer of this site, author of books on Web technologies, and member of the DotNetNuke core development team. If you're interested in the services provided by Patrick, visit his company Website at Santry.com.


Page Options:
format for printing  Format for Printer
email article  Email Page
add to your favorites   Add to Favorites
How would you rate the quality of this content?
Poor - - Excellent
Comments?
Overall Rating:
Comments Left:
  

 Latest Articles
  

 Latest News
  

 

Spotlight
Syndication

 


 


Digg This
 


DotNetNuke Platinum Benefactor

  
 

 Terms Of Use | Privacy Statement
 Copyright 2008 - Santry Technology Solutions, Box 172, Girard, PA 16417, (814) 774-0970