我遇到了一个问题,我真的无法理解它。我查看了各种可能的解决方案,实现了不同的代码片段,包括来自MSDN的代码片段。不幸的是,所有的解决方案都只是在我的问题上跳舞,经过几个小时的黑客攻击后,我终于离开了SOF大道。
我正在尝试从多维ArrayList中检索信息(POP3邮件列表)。以下代码创建ArrayList。我还在调试模式期间添加了ArrayList的值。
'*******************************************************************************
' Function Name : List
' Credit to : David Ross Goben
' Purpose : Get the drop listing from the maildrop
' :
' Returns : Any Arraylist of POP3Message objects
' :
' Typical telNet I/O:
'LIST (submit)
'+OK Mailbox scan listing follows
'1 2532 (record index and size in bytes)
'2 1610
'3 12345
'. (end of records terminator)
'*******************************************************************************
Public Function List() As ArrayList
If Not IsConnected() Then Return Nothing ' 'exit if not in TRANSACTION mode
Me.Submit("LIST" & vbCrLf) 'submit List request
If Not CheckResponse() Then Return Nothing ' 'check for a response, but if an error, return nothing
'
'get a list of emails waiting on the server for the authenticated user
'
Dim retval As New ArrayList 'set aside message list storage
Do
Dim response As String = Me.Response 'check response
If (response = "." & vbCrLf) Then 'done with list?
Exit Do 'yes
End If
Dim msg As New POP3Message 'establish a new message
Dim msgInfo() As String = Split(response, " "c) 'separate by spaces, which divide its fields
msg.MailID = Integer.Parse(msgInfo(0)) 'get the list item number
msg.ByteCount = Integer.Parse(msgInfo(1)) 'get the size of the email message
msg.Retrieved = False 'indicate its message body is not yet retrieved
retval.Add(msg) 'add a new entry into the retrieval list
Loop
Return retval 'return the list
End Function
不幸的是,我无法在调试模式下发布数据的图像,但我会尝试使用它的文本表示:
'List | Count = 125
' |
' (0) | Nothing
' (1) | Nothing
' |
' Mail.POP3Message | Nothing
' |
' ByteCount | 492334
' MailID | 1
' Message | Nothing
' Retrieved | False
当我检查列表中是否有任何项目时,它会返回有效的项目数。
'Get message list from pop3 server and populate dvgMsgList
dgvMailSettings.Rows(12).Cells(1).Value = "retrieving LIST of messages"
Try
For Each msg In srvPOP3.List
MsgBox("srvPOP3.List items = " & srvPOP3.List.Count)
Next
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error displaying Mail list")
End Try
如果有人可以为我阐明这个主题,我真的很感激,因为我真的需要了解这些数据:
|
ByteCount | 492334
MailID | 1
Message | Nothing
Retrieved | False
(我只对前两项感兴趣)