AspNNTP
1.x
About
AspNNTP
AspNNTP
allows you to retrieve and post articles to standard NNTP (Usenet/News)
servers. Features include:
- Retrieving
Articles
- Posting
Articles
- Multiple
File Attachments
- File
attachments support MIME and UUEncoding
- US
Ascii and ISO-8859-1 character sets
- PGP
Support
- Multiple
concurrent users (Tested with 15 concurrent connections)
AspNNTP
Installation
To
use this ASP component move the DLL into a subdirectory (like
\winnt\system32 for NT or \windows\system for Win95). Please use
the version of regsvr32 that is included with this component or
the version that comes with Microsoft ASP (they are the same version).
To
register the component on the system change to the directory where
you installed the DLL and type:
regsvr32
aspnntp.dll
Simple
Retrieve Example
Using
the component is as simple as
- Creating
the object
- Setting
a few properties
- Calling
the GetArticle method
The
following code demonstrates how to use AspNNTP 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 news server name
rem *************************************************************************
NNTP.Server = "msnews.microsoft.com"
rem *************************************************************************
rem * Set the news group to return articles from
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>"
else
Response.Write "<p>Unable to open Server or Newsgroup<br>" & VbCrLf
Response.Write "Failure was: " & NNTP.Response & "</p>" & VbCrLf
end if
rem *************************************************************************
rem * Make sure the object is destroyed
rem *************************************************************************
Set NNTP = nothing
%>
Notes
About Creating the NNTP Object
You
can create the NNTP object at two different points in time:
- Immediately
before retrieving or posting an article
- At
the session scope and saved as a session object
You
will have to decide when and where it is appropriate to create the
object based on your particular application. If you aren't sure
which way to create the object reference, or for typical usage,
you should create the object immediately usage. Your code would
look like this:
Set NNTP = Server.CreateObject("AspNNTP.Conn")
Creating
these local references, as demonstrated above, allow you to use
the object on multiple application threads at the same time.
To
create an object reference at the session level, your code might
look something like this:
if Not IsObject (session("NNTP")) then
Set NNTP = Server.CreateObject("AspNNTP.Conn")
Set session("NNTP") = NNTP
else
Response.write "Cached session object reference being used<p>"
Set NNTP = session("NNTP")
end if
About
purchasing AspNNTP
- The
registration license fee covers only one server CPU per license.
Dual-CPU servers require a license for each CPU.
- Evaluation
copies will expires. See the Expires property for details on determining
when your copy will expire.
- Attachments
are enabled in the registered version but not in eval copies.
- An
X-Header has been added (that is normally not displayed by most
news programs) showing who the component is registered to. When
you register make sure that the name you want displayed is included
in your registration information. Normally this will be a company
name. Changes will NOT be made once the product has been shipped
to users who register.
About
Upgrades
- Users
can upgrade for free for minor version changes. For example, upgrades
from version 1.00 to 1.99 are free. The upgrade from 1.99 to 2.0
may carry an additional license fee.
- The
latest version of the components are always available at http://www.serverobjects.com/products.htm.
If a fee is associated with obtaining the upgrade it will
be noted on that page.
Upgrade
Instructions
To
upgrade the component from a previous version please follow these
steps:
- Stop
all IIS related services such as Gopher, FTP and W3SVC.
- Change
to the directory where the component is located and type "regsvr32
/u aspnntp.dll"
- Move
the new copy of aspnntp.dll to the current directory and type
"regsvr32 aspnntp.dll"
- Restart
the necessary services.
Common
Problems
Server
object error 80040154.
This is the most common error reported. The error means that ASP
could not create the object. Causes include:
- You
never ran regsvr32 on the DLL. See installation section of this
document.
- You
registered the DLL with regsvr32 in one subdirectory and moved
it to another.
- IIS
does not have proper security permissions to access the DLL or
the directory you installed it to. See the ASP FAQ (http://www.signmeup.com/faq/)
for information on changing security.
- Your
server may be running low on memory.
- Your
evaluation copy has expired. If you purchased the product be sure
you followed directions to install your product key.
Note:
Some users have reported that restarting the server after registering
the DLL was required to use the component. This should not be necessary
but reportedly works in a few cases.
Server
object error 'ASP 0177:800401f3'.
This error means "Invalid class string" -- in other words
the call to CreateObject failed because the name object cannot be
found by the OLE sub-system. Causes include:
- You
really didn't run regsvr32 on the server after all.
- You
ran regsvr32 but it reported an error.
- Someone
modified security on part of the registry that's preventing the
OLE subsystem from reading all or part of the HKEY_CLASSES_ROOT
tree.
- The
name of the object you are trying to create was mispelled or is
incorrect.
Questions
about AspNNTP
| How
do I determine a cause of failure? |
If
the component can determine why a method call failed, that
information will be stored in the Response property. So, for
example, to print that information to the clients browser
you could add the following code:
if not NNTP.SetNewsgroup ("microsoft.test") then
if NNTP.Response <> "'' then
strError = NNTP.Response
else
strError = "Unknown"
end if
Response.Write "NNTP failure occured. Reason: " & strError
end if
|
| MessageIDs
aren't appearing. |
They
are probably wrapped in HTML tag identifiers <> so you'll
need to translate these characters or strip them before you
display to a Web browser. |
| How
do I thread messages? |
AspNNTP
does not internally support threading messages. If you want
to display message threads you'll have to parse the References
header and build the threaded message list. See the NNTP specs
available on the Net for details. |
| How
do I post a reply to a message? |
Grab
the message ID for the message and when you create a new Post
set the References field to the MessageID you are responding
to. |
| How
do I cancel a message? |
you
need to AddExtraHeaders as follows
Subject: cmsg cancel <msg_id_to_cancel>
Control: cancel <msg_id_to_cancel>
Approved: user@name.com
|
| AspNNTP
works great but sometimes I get "Server object error
'ASP 0177:80040154'". What is causing this? |
If
AspNNTP works fine, then it suddenly stops working and ASP
begins to report this error, then you've probably got a memory
leak under IIS/ASP. What has happened is that AspNNTP objects
can no longer be created. This could be caused by a) You haven't
installed the ASP patches that fix known ASP memory leaks
b) You have a filter or extension installed that's leaking
memory c) You have another component that is leaking memory.
AspNNTP
1.x has been run under BoundsChecker to verify that AspNNTP
does not leak memory.
|
| How
do I create a line-break in a message? |
Under
VBScript you can use the predefined constant VbCrLf. Simply
using a Chr(13) or a Chr(10) will not work --you must use
both. A Carriage-return and line-feed character are required
to create a new line in the message. |
| What
versions of PGP does AspNNTP support? |
AspNNTP
can support any encryption program that uses command-line
parameters. Using PGPPath and PGPParams you can specify input,
output and processing options. The current version of PGP
(5.0) does not support command-line parameters but the commercial
PGP 4.x does as well as the freeware (non-commercial use)
PGP 2.6.2. |
| Can
I repeatedly assign values to the BodyText property? and "The
message text keeps growing with each email I send." |
Yes,
the text will be appended to the message. Use ClearBodyText
if you need to clear the message text. |
| How
do I upgrade to the latest version? |
Download
the latest "eval" version and follow the upgrade
directions provided earlier in this document. |
| My
component is registered. Should the Expires property return
a date? |
No.
Registered versions return N/A for an expiration date. The
registration process (per the instructions you received) should
be run on the server. |
Technical Support
If you require technical support please see
our tech support page at http://www.serverobjects.com/support.htm
AspNNTP Properties
| Property |
Description |
| AttContentType |
Contains
the ContentType for a message attachment after you call NNTP.GetAttachmentInfo.
Example:
if NNTP.GetAttachmentInfo (intCount) then
Response.Write "ContentType=" & NNTP.AttContentType
|
| AttFileName |
Contains
the FileName for a message attachment after you call NNTP.GetAttachmentInfo.
Example:
if NNTP.GetAttachmentInfo (intCount) then
Response.Write "FileName=" & NNTP.AttFileName
|
| AttFileSize |
Contains
the FileSize for a message attachment after you call NNTP.GetAttachmentInfo.
Example:
if NNTP.GetAttachmentInfo (intCount) then
Response.Write "File Size=" & NNTP.AttFileSize
|
| AttachmentCount |
After
you have retrieved a message the AttachmentCount property contains
the number of attachements that were found within the message.
Example:
NNTP.Retrieve intMsgNumber
Response.Write "This message has " & _
NNTP.AttachmentCount & " attachments"
|
| AttachmentDirectory |
The
AttachmentDirectory property specifies where attachments will
be written to when the SaveAttachment method is called. |
| BodyText |
The
article body text. To clear the text after you have assigned
it, you can use the ClearBodyText Method.
Example:
NNTP.BodyText = "I'd like to let everyone know about this great new opportunity..."
|
| CharSet |
The
character set used by the article. By default CharSet is US
Ascii. Use CustomCharSet if you wish to use an alternate CharSet.
Valid
values:
- 1
= US Ascii
- 2
= ISO-8859-1
Example:
NNTP.CharSet
= 2
|
| ContentType |
The
ContentType property allows you to set the ContentType header
of the article's BodyText. If, for example, you wanted to send
HTML as the article's body, you could set ContentType = "text/html"
and News programs that support HTML content could properly display
the HTML text.
Note:
The ContentType property is ignored if you have file attachments.
Example:
NNTP.ContentType
= "text/html"
|
| Connected |
The
Connected property returns a value of true if the component
is currently connected to the Server or false if it is not connected.
Example:
If
NNTP.Connected then ...
|
| CurrentArticle |
The
CurrentArticle property indicates what article the component
currently points to. Immediately after opening a Newsgroup CurrentArticle
points to the FirstArticle value. Calling the NextArticle method
advances the CurrentArticle point to the next valid article
in the selected newsgroup.
Example:
NNTP.GetArticleByNumber(CurrentArticle)
|
| CustomCharSet |
If
you wish to use a character set besides the included types you
can set CustomCharSet to a character set string.
Example:
NNTP.CustomCharSet
= "ISO-2022" or
NNTP.CustomCharSet = "big5"
|
| DateTime |
The
DateTime property indicates the date and time of the article
posting. The standard format of this property is
Weekday,
DD-Mon-YY HH:MM:SS TIMEZONE
|
| Distribution |
This
optional property is used to alter the distribution scope of
the message. It has the same format as the Groups property.
User subscriptions are still controlled by Newsgroups, but the
message is sent to all systems subscribing to the newsgroups
on the Distribution line instead of the Newsgroups line. Thus,
a car for sale in New Jersey might have headers including
Newsgroups:
net.auto,net.wanted
Distribution: nj.all
so
that it would only go to persons subscribing to net.auto or
net.wanted within New Jersey. The intent of this header is
to further restrict the distribution of a newsgroup, not to
increase it. A local newsgroup, such as nj.crazy-eddie, will
probably not be propagated by sites outside New Jersey that
do not show such a newsgroup as valid. Wildcards in newsgroup
names in the Distribution line are allowed. Followup articles
should default to the same Distribution line as the original
article, but the user can change it to a more limited one,
or escalate the distribution if it was originally restricted
and a more widely distributed reply is appropriate.
|
| Encoding |
The
encoding type for attachments. The default setting is MIME.
Valid
values:
Example:
NNTP.Encoding
= 1
|
| Expires |
If
the component is an eval version the expires property will return
the date that the component quits functioning.
Example:
Response.Write
"Component Expires: " & NNTP.Expires
|
| ExpirationDate |
This
property value, if present, is in a legal USENET date format.
It specifies a suggested expiration date for the article. If
not present, the local default expiration date is used. If you
are posting a new article, this field can be set to expire the
article at a specific date & time. |
| FirstArticle |
Once
a Newsgroup name has been set using the SetNewsGroup method,
the FirstArticle property contains the article number of the
first article available on the selected newsgroup.
Example:
NNTP.GetArticleByNumber(FirstArticle)
|
| FollowUpTo |
This
property has the same format as Groups. If present, follow-up
articles are to be posted to the newsgroup(s) listed here. If
this property value is not present, followups are posted to
the newsgroup(s) listed in the Groups property. This property
is filled in once an article's headers have been read using
either GetArticleHeaders or a call to one of the GetArticle
methods. |
| FromName |
The
article originators name.
Example:
NNTP.FromName
= "Joes Widget Shop"
|
| FromAddress |
The
article originators email address.
Example:
NNTP.FromAddress
= "joe@widgets.com"
|
| Groups |
The
Groups property specifies which newsgroup or newsgroups the
article belongs in. Multiple newsgroups may be specified, separated
by a comma. Newsgroups specified must all be the names of existing
newsgroups, as no new newsgroups will be created by simply posting
to them.
Wildcards
(e.g., the word "all") are never allowed in aNewsgroups
line. For example, a newsgroup "net.all" isillegal,
although a newsgroup name "net.sport.football" is
permitted.
Example:
NNTP.Groups
= "microsoft.iis4.activeserverpgs,microsoft.iis4.general"
|
| LastArticle |
Once
a Newsgroup name has been set using the SetNewsGroup method,
the LastArticle property contains the article number of the
last article available on the selected newsgroup.
Example:
NNTP.GetArticleByNumber(LastArticle)
|
| Lines |
MessageID
returns the number of lines in an article as indicated by the
message hearder for the current article. This property is filled
in once an article's headers have been read using either GetArticleHeaders
or a call to one of the GetArticle methods. |
| MessageID |
MessageID
returns the message ID for the current article. This property
is filled in once an article's headers have been read using
either GetArticleHeaders or a call to one of the GetArticle
methods.
The
Message-ID line gives the article a unique identifier. The
same message ID may not be reused during the lifetime of any
article with the same message ID.
In
order to conform to RFC 822, the Message-ID
must havethe format
"<"
"unique" "@" "full domain name"
">"
where
"full domain name" is the full name of the host
at which the article entered the network, including a domain
that host is in, and unique is any string of printing ASCII
characters, not including "<", ">",
or "@". Forexample, the "unique" part
could be an integer representing a sequence number for articles
submitted to the network, or a short string derived from the
date and time the article was created.
Example:
NNTP.MessageID
= "01bc8665$d4b630e0$f6506ca3@localispname.net"
|
| NewsGroups |
Returns
a variant array of Newsgroups on the current NNTP server. See
nntp5.asp for a demo on how to enumerate the newsgroups. |
| NNTPLog |
If
you need to debug the session provide a log file name here.
Make sure the IUSR_XYZ IIS user has security that allows the
component to write to this file. Warning: Do not use this setting
in situations where multiple users can access this component
at the same time. This is for single user debugging ONLY!
Example:
NNTP.NNTPLog
= "c:\nntplog.txt"
|
| Organization |
The
text of this property is a short phrase describing the organization
to which the sender belongs, or to which the machine belongs.
The intent of this line is to help identify the person posting
the message, since site names are often cryptic enough to make
it hard to recognize the organization by the electronic address.
Example:
NNTP.Organization
= "Joe's Widgets"
|
| Password |
This
optional property is used when the Server you are connecting
to requires a username and password to connect.
Example:
NNTP.Password
= "123456"
|
| PGPPath |
The
path where PGP is located. |
| PGPParams |
Parameters
that PGP will use to process message. |
| References
|
This
property lists the message ID's of any articles prompting the
submission of this article. It is required for all follow-up
articles, and forbidden when a new subject is created.
The
purpose of the References header is to allow articles to be
grouped into conversations by the user interface program.
This allows conversations within a newsgroup to be kept together,
and potentially users might shut off entire conversations
without unsubscribing to a newsgroup.
NNTP.References
="<01bc8665$d4b630e0$f6506ca3@localispname.net>"
|
| ReplyTo |
If
present, mailed replies to the author should be sent to the
name given here. Otherwise, replies are mailed to the name on
the FromAddress property.
Example:
NNTP.ReplyTo
= "joe@localispname.net"
|
| Response |
The
Response property returns any error messages that may occur. |
| Server |
The
Server property specifies which NNTP server the component should
attempt to connect to.
Example:
NNTP.Server
= "msnews.microsoft.com"
|
| Subject |
The
Subject line tells what the article is about. It should be suggestive
enough of the contents of the article to enable a reader to
make a decision whether to read the article based on the subject
alone. If the article is submitted in response to another article
(e.g., is a "followup") the default subject should
begin with the four characters "Re: " and the References
line is required.
Example:
NNTP.Subject
= "Stock split announced!"
|
| SuppressMsgBody |
The
SuppressMsgBody property is true by default and is used in conjuction
with the NNTPLog property. When NNTPLog is set to a file and
SuppressMsgBody is true the log file receives a copy of the
article text. If SuppressMsgBody is false the article text is
not sent to the log. |
| TimeOut |
Timeout
is the maximum time that AspNNTP should wait for a response
from the remote server. The default is 45 seconds.
Example:
NNTP.Timeout
= 20
|
| TotalArticles |
The
TotalArticles property returns the total number of articles
available for the newsgroup you selected with the SetNewsgroup
method.
Response.Write
"There are " & NNTP.TotalArticles & "
in this group.<br>"
|
| UserName |
This
optional property is used when the Server you are connecting
to requires a username and password to connect.
Example:
NNTP.UserName
= "123456"
|
| Version |
Gets
the internal component version number.
Example:
Response.Write
"Component Version: " & NNTP.Version
|
| WordWrap |
The
WordWrap property is off by default. Setting WordWrap to true
causes the article body to wordwrap at the position specified
by the WordWrapLen property. This is only used during a POST
operation. |
| WordWrapLen |
The
WordWrapLen property is set to 70 by default. You can modify
the position that wordwrap occurs by changing this value. |
ASPMail Component Methods
| Method |
Parameters |
Return Value |
Description |
| AddAttachment |
Filename
to attach to message.
Example:
NNTP.AddAttachment
"p:\shipping\proddsk1.zip"
|
True
or False |
Adds
attachments to current article.
Make
sure that the IUSR_XYZ IIS user, or the authenticated user
has security rights that allow the component to read the necessary
files! Note: Attachments are not supported in the eval version
|
| AddExtraHeader |
A
string value that forms a proper NNTP Header
Example:
NNTP.AddExtraHeader
("HeaderName: HdrValue")
|
True
or false. Returns true if Header was added. |
Adds
extra Headers to the article envelope. |
| ClearAttachments |
None
Example:
NNTP.ClearAttachments
|
None |
Clears
any attachments that were previously set. |
| ClearBodyText |
None |
None |
Clears
any text assigned to the articless body which may have
been set previously by using the BodyText property. |
| ClearExtraHeaders |
None |
None |
Clears
any extra Headers that were set by use of AddExtraHeader. |
| GetAllNewsgroups |
String
specifying file to retrieve Newsgroup listing from. |
True/False |
If
an empty string is passed as the parameter the list of Newsgroups
is retrieved from the Server. |
| GetArticleByID |
String
specifying a known MessageID for a article that was previously
posted. |
True/False |
Retrieves
the article and places the header values into their appropriate
properties (such as FromName, FromAddress, Subject, BodyText,
Organization, Date etc...) |
| GetArticleByNumber |
Integer
value indicating the message number on the server. |
True/False |
Retrieves
the article and places the header values into their appropriate
properties (such as FromName, FromAddress, Subject, BodyText,
Organization, Date etc...) |
| GetArticleHeaders |
None |
True/False |
Retrieves
the CurrentArticle headers only and places the values into their
appropriate properties (such as FromName, FromAddress, Subject,
Organization, Date etc...) |
| GetAttachmentInfo |
Integer
value indicating which message attachment you want to get the
properties for. |
N/A |
GetAttachment
Info will get the properties for the specified attachment and
fill in the AttContentType, AttFileName and AttFileSize properties. |
| GetBodyTextFromFile |
strInputFile,
bolEraseInputFile, bolShowWindow |
True/False |
Used
for posting messages this method loads article's body text from
a file. Optionally runs PGP on the message text (See PGPPath
and PGPParams). |
| GetHeaderField |
String
parameter specifying which article header to return. |
String
value of header specified it it exists for the current retrieve
article. |
Once
an article's headers have been retrieved using GetHeaders or
a GetArticle call, the article headers are parsed into the standard
properties. But some custom or limited-use header fields are
not parsed. These are still available by calling this method
with the desired header field as the parameter. |
| GetNextArticleHeaders |
Integer
value specifying how many headers to retrieve |
Variant
array of variants. |
You
can retrieve multiple headers using this method. The variant
array returns the following items in the following order:
ArticleID
Subject
|
| NextArticle |
None |
True/False |
Moves
the article pointer to the next legal article. |
| PreviousArticle |
None |
True/False |
Moves
the article pointer to the previous legal article. |
| PrepareToPost |
None |
None |
Clears
all header fields and the BodyText to prepare the component
for a new Post. This should always be called before filling
in property values for a new article post. |
| PostArticle |
None |
True/False |
Posts
a new article to the server. |
| SaveAttachment |
Integer
value indicating which attachment to save. |
True
or False |
SaveAttachment
will save an attachment to the AttachmentDirectory's path. SaveAttachment
will attempt to determine the proper file name before saving. |
| SaveNewsgroupList |
String
value indicating a filename to save the newsgroup listing to. |
True/False |
Saves
the newsgroup list to the specified file |
| SetNewsgroup |
String
value of newsgroup component should open. |
True/False |
Attempts
to open the specified newsgroup. FirstArticle, CurrentArticle
and TotalArticles are initialized when SetNewsGroup is called. |
|