FreePOP ActiveX control
Version 4.0.1
August 7, 2000
Description
FreePOP is an ActiveX control that allows read/write access to a POP3 mailbox and the messages in the mailbox. This ActiveX control was developed with Microsoft Visual Basic 6.0-SP4.
Possible uses
Why it was created?
Why Free?
Limitations
Notes
Legal stuff
Support
Contact information
Please use the email address FreePOP@harm.net for any communications regarding the FreePOP ActiveX control. The homepage for the FreePOP ActiveX control is: http://www.harm.net/FreePOP
Futures
Due to the availability of reasonably priced full featured POP mail controls, further development on this project will not be likely. Bug fixes will certainly be addressed as they are reported.
Author information
Glenn Harm is employed by a large computer company as a computer consultant. His current expertise is working on large scale Microsoft Exchange Server deployments. He also enjoys all possible ways to keep up with the changing face of computer technology and spends way too much time with his computer and the Internet.
Source Code
The Visual Basic source code for FreePOP is now available! Information can be obtained by going to: http://www.harm.net/FreePOP/FPsource.asp
How can you help?
FAQ (Frequently Asked Questions)
Q: Are attachments or HTML messages "decoded" or "translated"? A: FreePOP only returns the "raw" message sent by the POP server. If the message is encoded in any way or if it contains any attachments, it is the responsibility of the programmer to decode them into something that is useful to the calling program. |
Q: How do I send email with FreePOP? A: FreePOP emulates the POP3 protocol which is mailbox (receiving) only. SMTP is the protocol for sending email. Go to ActiveX.com and search on SMTP. |
Q: Why not build in support for sending email (SMTP)? A: Unfortunately, SPAM and Unsolicited Commercial Email (UCE) is a big problem on the Internet. I don't want to be part of the problem by giving Spammers a free tool to use for sending email. Unfortunately, this penalizes people who would use it correctly--fortunately, there are other tools (see the previous question) out there that fill this need. |
Q: Where can I get further information on decoding messages or attachments? A: Purchase the book "Programming Internet Email" by David Wood from O'Reilly. ISBN: 1-56592-479-7. You can order the book from Amazon.com. |
Q: I'm getting an error when I try to register or use the control downloaded from the "minimal" kit. A: Download the "full" kit and run the SETUP.EXE program. |
Q: Can I get the source code for FreePOP? A: Source code for FreePOP is available! Please check http://www.harm.net/FreePOP/FPsource.asp for up to date information. |
Q: How do I create an instance of FreePOP from ASP (Active Server Pages) or VBScript? A: Use the following code:
|
Q: Why can't I can't get FreePOP to work in ASP (Active Server Pages) or inside VBscript? A: For reasons that I'm not entirely sure of, when an object gets created via ASP or VBscript, the routine that initializes the control does not fire. The effect of this is that some default properties are not set correctly. To circumvent that, include the following assignments of properties before calling the .Connect method:
|
Q: Where can I get information on RFCs (Request for Comments)? A: One of many repositories of RFCs can be found at http://www.faqs.org/rfcs/rfcsearch.html |
Q: What is the RFC for POP3? A: FreePOP follows RFC 1939 and this RFC can be found at: http://www.faqs.org/rfcs/rfc1939.html |
FreePOP ActiveX control documentation
Installation
FreePOP Methods
Connect - This method initiates a connection to a POP3 server. It connects, sends the username and password and collects some information about the mailbox. See the Properties section for further information.
Example: FreePOP1.Connect
Disconnect - This method closes the connection previously made to a POP3 server.
Example: FreePOP1.Disconnect
SetCurrentMsg - This method selects a specific message on the POP3 server. The message headers are retrieved and put into various properties. See the Properties section for further information.
Example: FreePOP1.SetCurrentMsg 1
RetrieveCurrentMsg - This method retrieves the currently selected message from the POP3 server. It "reads" it only--it does NOT remove it from the POP3 server. See the Properties section for further information.
Example: FreePOP1.RetrieveCurrentMsg
DeleteCurrentMsg - This method marks the currently selected message for deletion on the POP3 server.
Example: FreePOP1.DeleteCurrentMsg
ResetDeletedMsgs - This method unmarks any messages that have been previously marked for deletion in the current POP3 session.
Example: FreePOP1.ResetDeletedMsgs
GetOtherHeader - This method allows you to retrieve other header lines than what are currently provided for you via Properties. For example: the MsgSubject property holds the subject line header, but there is not a property for the "Content-transfer-encoding" header. You can use the GetOtherHeader method to retrieve any header that you wish from the currently selected message. If the header line doesn't exist the returning string will contain "<not found>"
Example: Dim strHeaderLine
strHeaderLine = FreePOP1.GetOtherHeader("Content-transfer-encoding:")
WriteCurrentMsgToFile - This method retrieves the current message (including the headers) and places it in the passed filename.
Example: FreePOP1.WriteCurrentMsgToFile("c:\ msg.txt")
GetStringValueOfProperty - This method returns a true "String" value of any of the properties. All the properties are of type "Variant". This was added in reponse to a person using LabView which is somewhat particular on using typed data.
Example: strSubjectLine = FreePOP1.GetStringValueOfProperty("MsgSubject")
FreePOP Properties
POPHostname - This is a Read/Write property which is used to get/set the name of the POP3 server that you wish to connect to. The value can either be a raw TCPIP address or a DNS name.
Example: FreePOP1.POPHostname = "pop3.yourserver.com"
POPPort - This is a Read/Write property which is used to get/set the port the connect request to the POP3 server is done with. The default for this value is 110.
Example: FreePOP1.POPPort = 111
POPUsername - This is a Read/Write property which is used to get/set the username to use when connecting to the POP3 server.
Example: FreePOP1.POPUsername = "joeschmoe"
POPPassword - This is a Read/Write property which is used to get/set the password to use when connecting to the POP3 server.
Example: FreePOP1.POPPassword = "joespassword"
POPTimeout - This is a Read/Write property which is used to get/set the timeout value (in seconds) for all operations which require interaction with the POP3 server. The default value for this value is 10 seconds.
Example: FreePOP1.POPTimeout = 20
Status - This is a Read-Only property which holds a integer type value representing the status of a connection to a POP3 server.
Value of 0 means disconnected
Value of 1 means connected
StatusText - This is a Read-Only property which holds a text representation of the Status property.
Error - This is a Read-Only property which holds a integer type value representing any error that may have occurred from one of the FreePOP methods.
Value 0 = No error
Value 11 = Connection was accepted but no data received before timeout. Connection closed
Value 12 = Timeout waiting on connect request
Value 13 = Already connected
Value 14 = Error received from USER command:
Value 15 = Error received from PASS command:
Value 16 = Hostname cannot be blank
Value 17 = Username cannot be blank
Value 18 = Error received from STAT command:
Value 19 = Cannot set message number when disconnected
Value 20 = Cannot set message number less than or equal to 0 or greater than the message count
Value 21 = Error using the UIDL command:
Value 22 = Error using the TOP command:
Value 23 = Cannot retrieve message when disconnected
Value 24 = Cannot retrieve message number 0, use the SetCurrentMsg method
Value 25 = Error retrieving the message:
Value 26 = Error using the DELE (delete) command:
Value 27 = Cannot delete message when disconnected
Value 28 = Error using the RSET (reset) command:
Value 29 = Cannot reset deleted messages when disconnected
Value 30 = Error using the LIST command:
Value 31 = File error:Additionally Winsock may generate an error which can be reflected in the Error property of this control. The ErrorText property will give the text representation of these messages as well. For further information about the various Winsock errors that can occur, see the Visual Basic help file for the Winsock Control.
ErrorText - This is a Read-Only property which holds a text representation of the Error property.
MsgCount - This is a Read-Only property which holds the number of messages in the connected POP3 mailbox. This value is set during the Connect method.
MsgNumber - This is a Read-Only property which holds the number of the currently selected message. This value is set during the SetCurrentMsg method.
MsgUniqueID - This is a Read-Only property which holds a unique identifier provided by the POP3 server for the currently selected message. This value is set during the SetCurrentMsg method.
MsgHeaders - This is a Read-Only property which holds all the message headers of the currently selected message. This value is set during the SetCurrentMsg method.
MsgSubject - This is a Read-Only property which holds the "subject" line of the currently selected message. This value is set during the SetCurrentMsg method.
MsgFrom - This is a Read-Only property which holds the "from" line of the currently selected message. This value is set during the SetCurrentMsg method.
MsgReturnPath - This is a Read-Only property which holds the "Return-Path" line of the currently selected message. This value is set during the SetCurrentMsg method.
MsgReplyTo - This is a Read-Only property which holds the "Reply-To" line of the currently selected message. This value is set during the SetCurrentMsg method.
MsgDate - This is a Read-Only property which holds the "date" line of the currently selected message. This value is set during the SetCurrentMsg method.
MsgSizeInK - This is a Read-Only property which holds the size (in kilobytes) of the currently selected message. This value is set during the SetCurrentMsg method.
ConnectResponse - This is a Read-Only property which holds the initial response from the POP3 server when a connection is established in the Connect method. The main reason I included this was because some POP3 servers give the current time in GMT as part of their initial connection response.
MsgContents - This is a Read-Only property which holds the body of the currently selected message. This value is set during the RetrieveCurrentMsg method.
DebugMode - This is a run-time only property which can be set to True to initiate retrieving some debug information. This should be used only on request of the author.
DebugFile - This is a run-time only property for debug information, if the DebugMode property has been set to True. This should be used only on request of the author.
FreePOP Events
MsgReadStatus - This is an event that is called during a .RetrieveCurrentMsg or .WriteCurrentMsgToFile methods. Information available in this event are:
Example:
Private Sub FreePOP1_MsgReadStatus(lngMsgReadInK As Variant, lngMsgTotalInK As Variant, intPercentCompleted As Variant) Label1.Caption = CStr(intPercentCompleted) & "%" ProgressBar1.Min = 0 ProgressBar1.Max = lngMsgTotalInK ProgressBar1.Value = lngMsgReadInK End Sub
Example
Follow the below directions to set up an environment where you can process all messages in a POP3 mailbox.
1) Start a new project.
2) Go into Project/Components and ensure that the "Glenn Harm's FreePOP Control" control is available and checked.
3) Add a command button to the form.
4) Add a FreePOP control to the form. Ensure that it has the Name of FreePOP1
5) Add a Text box control to the form. Make it as big as possible and name it Text1. Set the MultiLine property to True, and the ScrollBars property to 2-Vertical
6) Copy and paste the below into the Code window of the form. Make appropriate changes for the POP server information
<START AREA TO COPY>
Private Sub Command1_Click() Dim intCount As Integer Command1.Enabled = False FreePOP1.POPHostname = "pop3.yourserver.com" FreePOP1.POPUsername = "yourusername" FreePOP1.POPPassword = "yourpassword" FreePOP1.Connect If FreePOP1.Error = 0 Then MsgBox FreePOP1.MsgCount, vbOKOnly, "Messages in mailbox" For intCount = 1 To FreePOP1.MsgCount FreePOP1.SetCurrentMsg (intCount) If FreePOP1.Error = 0 Then FreePOP1.RetrieveCurrentMsg Text1.Text = FreePOP1.MsgContents DoEvents If FreePOP1.Error = 0 Then ' Do whatever you want for each message here. MsgBox FreePOP1.MsgSubject, vbOKOnly, "Subject line" MsgBox FreePOP1.GetOtherHeader("Content-transfer-encoding:"), vbOKOnly, _ "An additional header" Else MsgBox FreePOP1.ErrorText, vbOKOnly, "Error during RetrieveCurrentMsg" End If Else MsgBox FreePOP1.ErrorText, vbOKOnly, "Error during SetCurrentMsg" End If Next FreePOP1.Disconnect Else MsgBox FreePOP1.ErrorText, vbOKOnly, "Error during Connect" End If Command1.Enabled = True End Sub
<END AREA TO COPY>
7) Run the project
Release History
Version 2.0.1 - Initial public release (February 15, 1998)
Version 2.0.2 (February 19, 1998)
Version 2.0.3 (March 15, 1998)
Version 2.0.4 (August 23, 1998)
Version 2.0.5 (Self release only)
Version 2.0.6 (August 6, 1999)
Version 2.0.7 (August 7, 1999)
Version 2.0.8 (August 9, 1999)
Version 3.0.1 (August 17, 1999)
Version 4.0.1 (August 7, 2000)
Bugs fixed
- In some situations (notably when the CPU was near 100%) that FreePOP would cause a runtime error of 40006 when the .Connect method was executing.
- Some headers were not being processed correctly if there were other similar headers.
- If values for POPPort, MsgCount, or MsgSizeInK were greater than 32,767 a runtime error would occur. These variables have been converted to be of type Long rather than Integer.
Changes
- Previously, the message headers and size of the message were read during the .SetCurrentMsg method. This caused unnecessary overhead for anyone just wanting to see if there were new email messages since last check (by keeping track of each messages .MsgUniqueID property and checking on successive calls). The headers and size of the message are now read on demand by retrieving one of the following properties: MsgHeaders, MsgSubject, MsgFrom, MsgReturnPath, MsgReplyTo, MsgDate, MsgSizeInK, or the GetOtherHeader method). Existing programs should function the same, but it would be wise to now check the .Error property after utilizing one of the above listed properties for the first time following a .SetCurrentMsg method call.
- The display name of the control (Seen from the Components selection dialog) has been changed from "Glenn Harm's FreePOP ...." to "FreePOP ..."
- An event named MsgReadStatus has been added. This event is raised as messages are being read and can be used to display status of the current message being downloaded. Status information available is:
- Message read so far (in K)
- Message size (in K)
- Percent completed
Special thanks to