- Products
- Purchase
Order Online Maintenance Renewal Resellers - Support
Helpdesk Online Documentation Web Forum - Our Clients
- About
About us Services Contact
Back to Tutorials list
POP3.RetrieveHeaders Method
Messages Collection
Back to Tutorials list
Downloading headers
The sample downloads headers for all the messages in the mailbox without downloading entire messages.
"From:", "To:" and "Subject:" fields are displayed for each downloaded message headers.
In ASP code, Server.HTMLEncode is used for encoding "<" and ">" characters (which often appear in e-mail addresses but not allowed in HTML) into their safe HTML equivalents. Visual Basic code does not require such encoding.
RetrieveHeaders is a key method of this sample.
[Visual Basic]:
Dim objPOP3, objMsg, objMsgs
' Create POP3 object
Set objPOP3 = CreateObject("MailBee.POP3")
' Unlock POP3 object
objPOP3.LicenseKey = "put your license key here"
' Set POP3 server name
objPOP3.ServerName = "mail.server.com"
' Set user credentials
objPOP3.UserName = "username"
objPOP3.Password = "password"
' Connect to the server and log in the mailbox
If objPOP3.Connect Then
' Download headers for all messages
Set objMsgs = objPOP3.RetrieveHeaders
If Not objPOP3.IsError Then
' Display "From:", "To:", "Subject:" for each message
For Each objMsg In objMsgs
MsgBox _
"From: " & objMsg.FromAddr & vbCrLf & _
"To: " & objMsg.ToAddr & vbCrLf & _
"Subject: " & objMsg.Subject
Next
Else
' Display error information
MsgBox "Error #" & objPOP3.ErrCode & ", " & objPOP3.ErrDesc
End If
' Close the connection
objPOP3.Disconnect
Else
' Display error information
MsgBox "Error #" & objPOP3.ErrCode
MsgBox "Server response: " & objPOP3.ServerResponse
End If
[ASP]:
<%
Dim objPOP3, objMsg, objMsgs
' Create POP3 object
Set objPOP3 = Server.CreateObject("MailBee.POP3")
' Unlock POP3 object
objPOP3.LicenseKey = "put your license key here"
' Set POP3 server name
objPOP3.ServerName = "mail.server.com"
' Set user credentials
objPOP3.UserName = "username"
objPOP3.Password = "password"
' Connect to the server and log in the mailbox
If objPOP3.Connect Then
' Download headers for all messages
Set objMsgs = objPOP3.RetrieveHeaders
If Not objPOP3.IsError Then
' Display "From:", "To:", "Subject:" for each message
For Each objMsg In objMsgs
MsgBox _
"From: " & Server.HTMLEncode(objMsg.FromAddr) & "<br>" & _
"To: " & Server.HTMLEncode(objMsg.ToAddr) & "<br>" & _
"Subject: " & Server.HTMLEncode(objMsg.Subject)
Next
Else
' Display error information
Response.Write "Error #" & objPOP3.ErrCode & ", " & objPOP3.ErrDesc
End If
' Close the connection
objPOP3.Disconnect
Else
' Display error information
Response.Write "Error #" & objPOP3.ErrCode & "<br>"
Response.Write "Server response: " & objPOP3.ServerResponse
End If
%>
See Also:POP3.RetrieveHeaders Method
Messages Collection