iASP_NNTP Component

The iASP_NNTP component lets you platform independently retrieve and post articles to standard NNTP (Usenet/News) servers. iASP_NNTP contains different types of properties and methods.

Use the following links to view the details

Properties

  • AttContentType
  • AttFileName
  • AttFileSize
  • AttachmentCount
  • AttachmentDirectory
  • BodyText
  • charSet
  • contentType
  • connected
  • currentArticle
  • customCharSet
  • dateTime
  • distribution
  • encoding
  • expires
  • expirationDate
  • firstArticle
  • followUpTo
  • fromName
  • fromAddress
  • groups
  • lastArticle
  • lines
  • messageID
  • newsGroups
  • NNTPLog
  • organization
  • password
  • pGPPath
  • pGPParams
  • references
  • replyTo
  • response
  • server
  • subject
  • suppressMsgBody
  • timeOut
  • version

Methods

Usage

Following steps are required in order to communicate with network news server using AspNNTP.Conn class:

  1. Create an object with IASPNntp.Conn class:

    Set NNTP  = Server.CreateObject("AspNNTP.Conn")

  2. Set the Remote NNTP Server by using setServer() method. This method creates a connection with the server at  port number 119.

    NNTP.setServer "msnews.microsoft.com"

  3. Set time by using setTimeout() method. This method is used to set the total time for communication.  The user may extend the time according to the requirements. By default timeOut is 45 seconds.  Use the following command to set timeOut:

    NNTP.setTimeout(45)

NOTE: Time is in seconds. An error will be generated if the server does not respond or if the connection is lost.

ASP Samples

Using the component is as simple as:

             1.Creating the object
             2.Setting a Newsgroup
             3.Setting a few properties

The following code demonstrates how to use iASP_NNTP from VBScript.

In this example we'll retrieve the first ten articles available on the msnews.microsoft.com server from the  newsgroup named microsoft.public.inetserver.misc.

  rem *************************************************************************
  rem *  Instantiate the NNTP object
  rem *************************************************************************

  Set NNTP = Server.CreateObject("AspNNTP.Conn")

  rem *************************************************************************
  rem *  Set the NNTP server .
  rem *************************************************************************

  NNTP.setServer  "msnews.microsoft.com "

  rem *************************************************************************
  rem *  Set existing Newsgroup to the server in order to
  rem *  get the properties related to the news articles.
  rem *************************************************************************

  if NNTP.SetNewsgroup ("microsoft.public.inetserver.misc") then

     Response.Write "First 10 postings - <p><table width="90%" border=1>"
     For intCount = 1 to 10

  rem *************************************************************************
  rem *  Retrieve the article by number
  rem *************************************************************************

        NNTP.GetArticleByNumber(NNTP.CurrentArticle)
        Response.Write "<tr><td>" & NNTP.currentArticle & "</td><td>"&NNTP.subject &_     "</td><td>" & NNTP.bodyText & "</td></tr>"

  rem *************************************************************************
  rem *  Point CurrentArticle to the next legal article number
  rem *  Note: Use this rather than looping from FirstArticle to LastArticle
  rem *        since some articles may no longer exist
  rem *************************************************************************

        NNTP.nextArticle()
     Next
     Response.Write "</table>"

     Response.Write "There are currently " & NNTP.getTotalArticles & _
                     " articles posted in group " & "microsoft.public.inetserver.misc" & "<br>" & VbCrLf
 end if

 rem *************************************************************************
 rem *  Make sure the object is destroyed.
 rem *************************************************************************

 Set NNTP = nothing

See Appendix A for more details of methods.
 

See Appendix C for more Error Code details.

Appendix A

Methods Description
void setServer(String NNTPServer) It establishes the connection with the NNTP server at 119 port and sets server and connected property.

 String getServer()
It returns the name of server, which is currently connnected.

 boolean setNewsgroup(String newsgroup)
It sets the existing Newsgroup.
Note:- server property must be set first.

 void  setBodyText(String bodyText)
It sets the bodyText property with the specified string.

 String   getBodyText()
It gets the bodyText property.

getArticleByNumber(int )
It retrieves the article from NNTP Server by number and set the related properties.
void setTimeout(int seconds) Timeout is the maximum Time that iASP_NNTP waits to get a response from the remote site. The default is 45 seconds.
Note:- Set the TimeOut in milliseconds.
int getTimeout()  It returns Timeout.
final String getAlias(); It  returns the alias as  "IASPNntp.Conn" 
String getUserName() It returns the  name of user for NNTP Server.
void setFromName(String) It sets  article originator’s name. 
String getFromName() It returns article originator’s name.. 
void setFromAddress(String) It sets article originator’s email address.
String getFromAddress() It return article originator’s email address.
void setOrganization(String) It sets organization name of the sender. 
String getOrganization() It returns organization name of the sender. 
void setSubject(String ) It sets the subject of an article to be posted.
String getSubject() It gets the subject of  the current article.
void setUserName(String) It sets the  name of the user for NNTP Server.
String getMessageID() It gets the messageID of the current article .
boolean isConnected() It returns the status of  the connected property .
void setSuppressMsgBody(boolean) It sets the suppressMsgBody to be true or false depending if the bodyText of the retrieving article has to be saved or not . 
boolean isSuppressMsgBody() It returns the status of  the suppressMsgBody property .
void setGroups(String) It sets the group(s) to which the article needs to be posted.
String getGroups() It returns the groups property. It specifies which newsgroup or newsgroups the current article belongs to.
String getResponse() It returns the last Response which is send  by the server.
void setPGPPath(String)  It sets the path where PGP (Pretty Good Privacy)  is located.
void setPGPParams(String) It sets  the PGPParams by the  user.
String getPGPParams() It returns the PGP parameters .
String getPGPPath() It returns the  path  where PGP is located .
void setPassword(String) It sets the password property for server authentication.
String getPassword() It returns the password  property value, which is set for authentication.
void setTimeOut(int) It sets  the maximum time that iASP_NNTP should wait to get  a response from  the remote server.
int getTimeOut() It returns timeout .
void setFollowUpTo(String) It sets the list of the newsgroup(s) to which the article is to be posted.
String getFollowUpTo() It returns the list of newsgroup(s) to which the current article is  posted.
void setReferences(String) It sets the message ID's of any articles prompting for submission of the article.
String getReferences() It returns the references of an article. 
void setReplyTo(String) It sets the author name. Mailed replies to the author should be sent to the name specified.
String getReplyTo() It returns author name as replyTo property.
boolean isWordWrap() It returns the status(true or false) of wordWrap .
void setWordWrapLen(int) It sets the length of  the wrapping characters by the user.
By default wordWrap length is 70.
int getWordWrapLen() It returns the length of  the wrapping characters.
String getVersion() It returns the version  of the component.
void setCharSet(int) It sets the character set used by the article. By default CharSet is US Ascii.
Valid values: 
              1 = US Ascii 
              2 = ISO-8859-1 
int getCharSet() It returns  the character set used by the current retrieved article  .
void setCustomCharSet(String) It sets  the custom CharSet if one wish to use an alternate CharSet  .
String getCustomCharSet() It  returns the CustomCharSet used by the article .
void setEncoding(int) It sets the encoding type for attachments to be send. The default setting is MIME.
Valid values:
                     1 = UUEncoded 
                     2 = MIME 
int getEncoding() It retrieves  the encoding type of the current attachment. 
void setDistribution(String) It sets the distribution property whenever the article is ready for posting . This optional property is used to alter the distribution of the message.
String getDistribution() It retrieves the distribution property of the current article .
int getLines() It retrieves the number of lines from the headers of the currently retrieved article.
void setContentType(String) It sets the content type of the BodyText of the  article to be posted. 
String getContentType() It returns the content type of the BodyText of the current article .
String getAttFileName() It returns the name of file attached with the recently retrieved article. 
String getAttContentType() It returns the content type of the attachment of the retrieved article .
int getAttFileSize() It returns size of  file attached with the retrieved article.
int getAttachmentCount() It returns the number of  attachement(s) with the recently retrieved article.
void setAttachmentDirectory(String) It sets the path to which attachment should be saved. 
String getAttachmentDirectory() It returns the attachmentDirectory property in  order to specify where attachments will be written when the saveAttachment() method is called. 
void setExpirationDate(String) It sets a  suggested expiration date for the article to be posted. It must  be in a legal USENET date format
String getExpirationDate() It returns  suggested expiration date for the article.
String getExpires() It returns date,after which component should not be valid for functionality.
void setDateTime(String) It sets the current date and time whenever article is ready for posting. The date should have the following format
Weekday, DD-Mon-YY HH:MM:SS TIMEZONE
String getDateTime() It returns the date and time of the article posting.
int getCurrentArticle() It returns the article number of the given Newsgroup 
int getFirstArticle() It returns the first Article number of the specified newsgroup. 
int getLastArticle() It returns the last article number.
int getTotalArticles() It returns the total number of articles present in the given newsgroup .
void setNNTPLog(String) It sets the Log file name which saves all operations and responses  send by the NNTP server. 
String getNNTPLog() It returns the NNTPLog file name. 
boolean nextArticle() It advances the current Article pointer by one and returns true if it makes the increment successfully in the pointer; otherwise false will return. 
boolean previousArticle() It recedes the current Article pointer by one and returns true if it makes the decrement successfully in the current pointer; otherwise false will return.
boolean saveNewsgroupList(String) This method attempts to save the list of existing newsgroups in the specified file.
boolean getAllNewsgroups(String) This method attempts to get the list of newsgroup either from the specified file when the file name is  not null or from the server when the input parameter is void.
void prepareToPost() This method attempts to reset the properties before posting. 
boolean addExtraHeader(String) This method attempts to add an extra header to the headers of the current article.
NNTP.addExtraHeader  ("HeaderName: HdrValue")
void clearExtraHeader() This method clears all extra headers that were added by the addExtraHeaders()
String getHeaderField(String) This method attempts to extract the headers which are not parsed before. This will enable the user to pass the required field to this method. If it is present in the internal extraHeader  property it will retrieve the value of that field, otherwise null will return.
String[] getAllNewsgroups()  It retrieves the list of existing newsgroups from the server. 
boolean getAttachmentInfo(int) It  retrieves the information related to the specified  attachment  with the current article. It also initializes the
local properties related to an attachment like attContentType,attFileName etc.
boolean saveAttachment(int) It saves the specified attachment to the attachmentDirectory  if it is set using setAttachmentDirectory();  otherwise to the root. 
void clearAttachments() It clears all attachments of the current article. 
boolean addAttachment(String) It adds attachment to the current article.
void clearBodyText() It clears the bodyText of the current  article.
boolean getArticleByNumber(int) It retrieves the article by giving its number.
It also initializes the properties related to that article.
It returns true if the article is retrieved successfully and false otherwise.
ResponseCode for this action is 220.
boolean getArticleHeaders() It retrieves the headers of  the current  article and returns true if the header is retrieved successfully and false otherwise.
boolean getBodyTextFromFile(String, boolean, boolean) It gets the text from the specified file and fills it to the bodyText property of the article to be posted.
First param is the name of file whose content is to be read.
Second param is the true or false depending whether the file can be
erased or not after filling the bodyText of the article.
Third param  shows window status.
This method returns true if the file is successfully  read and false otherwise.
boolean getArticleByID(String) It retrieves the article by giving its messageID.
It also initializes the properties related to that article.
It returns true if the article is retrieved successfully and false otherwise.
String getNextArticleHeaders(int) It retrieves the multiple headers of the next articles.
The input param specify the number of headres to be retrieved.
boolean postArticle() It posts the new article to the current Newsgroup .
It works only when the posting is allowed to that newsGroup.
ResponseCode for this action is 314.

Appendix B

Type  Variables Default Values 
 boolean  Connected  false
 byte  Err  -1
 String attContentType  null
 String  attFileName null
 int  attFileSize 0
 int attachmentCount 0
String attachmentDirectory null
String bodyText null
 int charSet 0
 String contentType null
 boolean connected false
 int currentArticle 0
String customCharSet null
String dateTime null
String distribution null
 int encoding 1
 String expires null
 String expirationDate null
 int firstArticle 0
 String followUpTo null
 String fromName null
 String fromAddress null
 String groups null
 int lastArticle 0
 int lines -1
 String messageID null
 String[] newsGroups null
 String NNTPLog null
 String organization null
 String password null
 String pGPPath null
 String pGPParms null
 String references null
 String replyTo null
 String response null
 String server null
 String subject null
 String suppressMsgBody null
 int timeOut 45 seconds
 float Version  1.0

Appendix C

Errors Constants
INPUT_OUTPUT_ERROR  0
NO_CONNECTION_ESTABLISHED 1
HOST_NOT_FOUND  2
UNKNOWN_NEWS_GROUP  3
NEWSGROUP_IS_NOT_SELECTED  4
UNWANTED_ARTICLE  5
TRANSFER_FAILED  6
TRANSFERRED_REJECTED  7
POSTING_FAILED  8
UNRECOGNIZED_COMMAND  9
SYNTAX_ERROR  10
ACCESS_DENIED  11
PROGRAM_FAULT  12
ARTICLE_NOT_FOUND  13
POSTING_NOT_ALLOWED  14
CURRENT_ARTICLE_NOT_SELECTED  15
NEXT_ARTICLE_NOT_PRESENT  16
PREVIOUS_ARTICLE_NOT_PRESENT  17
ERROR_IN_PARSING_HEADER  18
THERE_IS_NO_ATTACHMENT  19
OUT_OF_RANGE  20
FILE_IS_HIDDEN  21
FILE_DOES_NOT_EXIT  22
FILE_CAN_NOT_CREATED  23
SERVICE_DISCONTINUED  24
UN_INITIALIZED_ATTRIBUTE  25
INVALID_ASSIGNMENT  26
TIME_OUT_INTERRUPTION  27
CANNOT_RETRIEVE_NEWSGROUP_LIST  28
AUTHENTICATION_REQUIRED  29
WORD_WRAPPING_ERROR  30
ERROR_IN_SOCKET  31
ERROR_IN_PGP_EXECUTION  32
PERMISSION_DENIED 33

If you require technical support please send complete details about the problem you are having to support@halcyonsoft.com.


Copyright © 1998-2002, Halcyon Software Inc. All rights reserved.