14.2 News Object

Establishes a connection to the News server based on the specified IP address and provides access to the articles and groups available on that server.

14.2.1 Server property

Sets and gets the IP address of the News server.

Syntax

 Object.Server
 

Type

String.

Attributes

Read/write.

Examples

This example sets the IP address of the News server and establishes NNTP connection.

 ’Connect to the NNTP server
 Set news =CreateObject("UCX:INews.news") 
 ’Set the IP address
 news.Server = "192.233.80.143"
 ’Establish connection with the server
 Status = news.Connect()
 Print "The NNTP connection status is "status
 ’Disconnect
 If(news.Disconnect()) Then
   Print "Disconnected from the server"
 Else
   Print "Connection exists"
 End if
 

14.2.2 Timeout property

Sets and gets the waiting time (in milliseconds) for receiving request from the News server for command execution.

Syntax

 Object.Timeout
 

Type

Long.

Attributes

Read/write.

Remarks

By default, the waiting time will be 6000 milliseconds.

Examples

This example sets the waiting time for receiving request from the News server, to 60 milliseconds.

 ’Set the time out periodSet news =CreateObject("UCX:INews.news")
 ’Set the IP address
 news.server = "192.233.80.143"
 ’set the timeout period
 news.Timeout = 600
 ’Establish connection with the server
  news.Connect()
 

14.2.3 Articles method

Querys the News server for a collection of articles having specified a article or a range of IDs and existing in specified groups.

Syntax

 Object.Articles(
  Groupname As String,
  MessageIDs As String)
 

Parameters

GroupName
The string that specifies the group in which the particular articles collection is to be queried
MessageIDs
The string that specifies a message ID or a range of IDs corresponding to the articles, for querying the News server. The message IDs can be given as:
  • An article number.
  • An article number followed by a dash (-) to indicate all the successive articles.
  • An article number followed by a dash (-) and the next article number.

Return values

Articles collection objects.

Examples

This example gets the articles collection objects comprising reference to the articles collection with message ID "1" and existing in the group "Test".

 Gets the groups available on the server
 Set news=CreateObject("UCX:INews.news") 
 ’Set the IP address
 news.Server = "164.99.150.93"
 ’Establish connection with the server
 news.Connect()
 Set articles = news.Articles("Test","1")
 For each article in articles
 Print article.Author 
 Next
 

14.2.4 Command method

Sends a NNTP command to the News server.

Syntax

 Object.Command(
  Cmd As String)
 

Parameters

Cmd
The string that contains NNTP command to be sent to the News server.

Return values

Response data from the News server corresponding to the command sent to it.

Examples

This example sends the HELP command to the News server and returns all the commands.

 ’Send command to NNTP server
 Set news =CreateObject("UCX:INews.news") 
 ’Set the IP address
 news.Server = "192.233.80.143"
 ’Establish connection with the server
 Status = news.Connect()
 ’Type the command to be sent to the server
 Print News.Command("HELP")
 

14.2.5 CreatePostArticle method

Creates an Article object for posting a new article or reply to an existing article to the News server.

Syntax

 Object.CreatePostArticle()
 

Parameters

None.

Return values

Article object for posting a new article or replying to an existing article.

Remarks

The Post method is valid only for the articles created using CreatePostArticle method.

Examples

This example creates a post article with the given details under the group Test and post it.

 ’Create post article
 Set news = CreateObject("UCX:INews.news") 
 ’Set the IP address
 news.server = "164.99.150.93"
 ’Establish connection with the server
 Status = news.Connect()
 set article = news.Createpostarticle()
 article.Author =  "Sudha"
 article.Body =  "test message"
 article.Subject = "testing"
 article.Reference = "0"
 ’Give the newsgroup in which the article is to be created
 article.Newsgroups = "test"
 article.Date = cdate(date) 
 print article.Date
 article.Post()
 ’Post the created article
 Status = article.Post()
 Print "The article creation status: "&status
 

14.2.6 Connect method

Establishes NNTP connection to the News server.

Syntax

 Object.Connect()
 

Parameters

None.

Return values

Boolean. Returns TRUE if connection is established successfully.

Remarks

The IP address of a valid News server should be assigned to the server property, before calling the Connect() method.

Examples

This example sets the IP address of the News server and establishes an NNTP connection.

 ’Connect to the NNTP server
 Set news =CreateObject("UCX:INews.news") 
 ’Set the IP address
 news.Server = "192.233.80.143"
 ’Establish connection with the server
 Status = news.Connect()
 Print "The NNTP connection status is "status
 ’Disconnect
 If(news.Disconnect()) Then
   Print "Disconnected from the server"
 Else 
   Print "Connection exists"
 End if
 

14.2.7 Disconnect method

Disconnects the NNTP connection with the News server.

Syntax

 Object.Disconnect()
 

Parameters

None.

Return values

None.

Examples

This example sets the IP address of the News server, establishes NNTP connection with the server.

 ’Connect to the NNTP server
 Set news =CreateObject("UCX:INews.news") 
 ’Set the IP address
 news.Server = "192.233.80.143"
 ’Establish connection with the server
 Status = news.Connect()
 Print "The NNTP connection status is "status
 ’Disconnect
 If(news.Disconnect()) Then
   Print "Disconnected from the server"
 Else 
   Print "Connection exists"
 End if
 

See Also

14.2.8 Groups method

Queries the News server for specific groups based on the given groupnames.

Syntax

 Object.Groups(
  [GroupName As String])
 

Parameters

GroupName
Optional.The string that contains the name of the group, for querying the News server.

Return values

Groups object comprising collection of all the groups currently available in the particular News server.

When the group name is specified, the groups object will have only one group corresponding to the given group name.

Examples

This example queries the News server and returns a Groups object containing a collection of all the groups.

 ’Gets the groups available on the server
 Set news =CreateObject("UCX:INews.news") 
 ’Set the IP address
 news.Server = "164.99.150.93"
 ’Establish connection with the server
 news.Connect()
 Set groups = news.Groups()
 Set group = groups.Item("Test")
 Print group.Name