Type | Description | |||
Command as String | A string expression that indicates the custom command being sent to the news server. | |||
String | A string expression that indicates the response of the news server to the command. |
The following samples show how we can handle the NEWNEWS command. The syntax for the NEWNEWS command is
NEWNEWS newsgroups date time [GMT] [<distribution>]
The NEWNEWS command gets a list of message-ids of articles posted or received to the specified newsgroup since "date" will be listed. The format of the listing will be one message-id per line, as though text were being sent. A single line consisting solely of one period followed by CR-LF will terminate the list. The samples use also the HEAD and BODY commands to get the header and the body for a specified article base on its identifier.
So, the command that we have to send to the server is "NEWNEWS vb.general " & n.Date(Date). The Command property will get the list of message-ids, line by line. We are using the Split function to get line by line from the response.
The following sample displays the articles that have been posted since yesterday, on a specified news group:
Dim WithEvents n As EXNNTPLibCtl.NNTP Private Sub Form_Load() Dim s As String, a() As String, i As Long Set n = New NNTP n.Connect "news.devx.com" s = n.Command("NEWNEWS vb.general " & n.Date(Date - 1)) a = Split(s, vbCrLf) For i = LBound(a) To UBound(a) Debug.Print "--------------------" Debug.Print n.Command("HEAD " & a(i)) Debug.Print "--------------------" Debug.Print n.Command("BODY " & a(i)) Next End Sub Private Sub n_Error(ByVal Command As String, ByVal Error As String) Debug.Print "Error: " & Error End Sub
The following sample displays all articles that have been posted since yesterday, from all news groups that start with "vb":
Dim WithEvents n As EXNNTPLibCtl.NNTP Private Sub Form_Load() Dim s As String, a() As String, i As Long Set n = New NNTP n.Connect "news.devx.com" s = n.Command("NEWNEWS vb.* " & n.Date(Date - 1)) a = Split(s, vbCrLf) For i = LBound(a) To UBound(a) Debug.Print "--------------------" Debug.Print n.Command("HEAD " & a(i)) Debug.Print "--------------------" Debug.Print n.Command("BODY " & a(i)) Next End Sub Private Sub n_Error(ByVal Command As String, ByVal Error As String) Debug.Print "Error: " & Error End Sub