EsPop - ActiveX Control
This control encapsulates the POP3 protocol and compile with MIME version 1.0. This means that it can be used to receive binary information as well as mail bodies containing characters like the Swedish åäöÅÄÖ. You can use this control to fetch mail from a POP server on a UNIX machine or like. There is no restriction on message sizes. The control also have methods that lets you extract attachments.
Transfer EsPop32.ocx to your \windows\system or \winnt35\system32 directory and register it by executing the command:
RegSvr32.exe can be found on the Visual Basic 4.0 CD-ROM and in our dll archive (www.eurosource.se). If RegSvr32.exe fails, it's probably because you don't have the MFC 4.0 DLL library installed on your system. This is available from many sources on the Internet including our ftp archive as MFCDLLS.ZIP. Regsvr32.exe is also included in this archive. If you want to check if you already got the files in mfcdlls.zip they are
New features in version 1.1
Cookbook or how to use the EsPop Control
Create a EsPop object for an ASP application
Use the object ID ESPOP.EsPopCtrl.1 when you create an instance of the
Connect to a POP server
The first property you should set is the POPServer using
Of course you have to use the IP-address if your own POP server. This property is saved with the control so you can also set it on once and for all in the property window.
The next thing you should do is to set the username and password to use for your POP session. You do this by
To connect to the POP server you need to have a link open to the POP server. Either through your LAN or by a RAS connection or some other dialup method. Our control EsRas is the perfect control to use if you want to establish a connection, fetch mail and then drop this connection.
To establish a connection with the POP server you just have to logon using something like the following
rv = EsPop1.Logon
While you are logged on you can fetch, delete and do all other operations that are available for mail on the server. When you have done your work on the server you use the LogOff method to terminate your POP session.
Disconnect from a POP server
You always have to logoff before you terminate a session with a POP server. Some systems even don't want to let you connect to the server again (until the POP server is restarted) if you don't do this. So please logoff before your terminate your POP session. This is done with the LogOff method
rv = EsPop1.LogOff
Get information about available mail on the server
When you are logged on to the POP server the NumOfMsg property contains the number of messages that is available on the server. The total size in bytes for all of these messages is available in the TotMsgSize property.
Number_Of_Messages = EsPop1.NumOfMsg
Get a specific message from the server
You use the GetMail method to retrieve a message from the POP server. The argument you give to this function should be the message number you want to get. The first message is numbered one (NOT zero) and the last message has the same index as the value in the NumOfMsg property.
MessagePath is another property that is important for message retrieval. Retrieved messages are always put in a temporary file. This file is defined by the MessagePath property. If you call GetMail without specifying a path a file is created for you in the windows temporary file directory and you can check this property after a successful message fetch to get the location and name of the file. If you want you can also set this property to a value before you call the MessagePath method. In this case the fetched message is stored at the end of that file and with a blank line separating multiple messages. Normal sized messages, that is with a size less than 32768, are also stored in there raw form in the Message property.
By using a file for message storage there is no upper limit to the size of the messages that you can fetch. This means that there is no problem to get messages that contain large file attachments. There is one problem though if you receive small messages and only use the message property to work with messages because you always also get the temporary file. There is two ways around this problem.
The following sample get message 3 from a POP server, deletes it and displays the message in a message box. This is only done for if it is a small message.
nMsgNo = 3
Note that there is no need to delete the messages on the server. If you don't do this the message will be available on the server the next time you connect. Also if you delete messages and then call the Reset method the message delete is canceled.
Using the status event
During lengthy operations the status event is a useful tool to inform your user about the progress of the work. If for instance you are downloading a large letter consisting of several big attachments you need a way to inform your customers of the state of things. The status event is your tool to do this.
At a start of a message download a status event with progress set to 0 is generated. You can directly feed this value to the gauge of your choice. Then during the message download you get status events with progress set to a number that represents the percentage of work done. And finally when all of the message is received a status event with progress set to 100 will be fired. Telling you or the user that all of the work with this message has been done.
The event procedure thus normally have this simple form
Private Sub EsPop1_Status(ByVal progress As Integer)
This property is set to true if the received message is a MIME 1.0 message.
If the received message is a MIME 1.0 message this property contains the boundary for the message.
If the received message is a MIME 1.0 message this property contains the Content type for the message. See the content event for information on possible values.
After a message has been retrived with either the GetMessage or the GetTop commands this property holds the date line from the header.
The error code from the last operation.
There are two types of error messages. One type is the POP3 reply codes and one is the WinSock error codes.
POP3 reply codes
WinSock error codes
10013 - WSAEACCES, Permission denied.
10048 - WSAEADDRINUSE, Address already in use.
10049 - WSAEADDRNOTAVAIL, Cannot assign requested address.
10047 - WSAEAFNOSUPPORT, Address family not supported by protocol family.
10037 - WSAEALREADY, Operation already in progress.
10053 - WSAECONNABORTED, Software caused connection abort.
10061 - WSAECONNREFUSED, Connection refused.
10054 - WSAECONNRESET, Connection reset by peer.
10039 - WSAEDESTADDRREQ, Destination address required.
10014 - WSAEFAULT, Bad address.
10064 - WSAEHOSTDOWN, Host is down.
10065 - WSAEHOSTUNREACH, No route to host.
10036 - WSAEINPROGRESS, Operation now in progress.
10004 - WSAEINTR, Interrupted function call.
10022 - WSAEINVAL, Invalid argument.
10056 - WSAEISCONN, Socket is already connected.
10024 - WSAEMFILE, Too many open files.
10040 - WSAEMSGSIZE, Message too long.
10050 - WSAENETDOWN, Network is down.
10052 - WSAENETRESET, Network dropped connection on reset.
10051 - WSAENETUNREACH, Network is unreachable.
10055 - WSAENOBUFS, No buffer space available.
10042 - WSAENOPROTOOPT, Bad protocol option.
10057 - WSAENOTCONN, Socket is not connected.
10038 - WSAENOTSOCK, Socket operation on non-socket.
10045 - WSAEOPNOTSUPP, Operation not supported.
10046 - WSAEPFNOSUPPORT, Protocol family not supported.
10067 - WSAEPROCLIM, Too many processes.
10043 - WSAEPROTONOSUPPORT, Protocol not supported.
10041 - WSAEPROTOTYPE, Protocol wrong type for socket.
10058 - WSAESHUTDOWN, Cannot send after socket shutdown.
10044 - WSAESOCKTNOSUPPORT, Socket type not supported.
10060 - WSAETIMEDOUT, Connection timed out.
10035 - WSAEWOULDBLOCK, Resource temporarily unavailable.
11001 - WSAHOST_NOT_FOUND, Host not found.
(OS dependent) - WSA_INVALID_HANDLE, Specified event object handle is invalid.
(OS dependent) - WSA_INVALID_PARAMETER, One or more parameters are invalid.
(OS dependent) - WSAINVALIDPROCTABLE, Invalid procedure table from service
(OS dependent) - WSAINVALIDPROVIDER, Invalid service provider version number.
(OS dependent) - WSA_IO_PENDING, Overlapped operations will complete later.
(OS dependent) - WSA_IO_INCOMPLETE, Overlapped I/O event object not in signaled
(OS dependent) - WSA_NOT_ENOUGH_MEMORY, Insufficient memory available.
10093 - WSANOTINITIALISED, Successful WSAStartup not yet performed.
11004 - WSANO_DATA, Valid name, no data record of requested type.
11003 - WSANO_RECOVERY, This is a non-recoverable error.
(OS dependent) - WSAPROVIDERFAILEDINIT, Unable to initialize a service
(OS dependent) - WSASYSCALLFAILURE, System call failure.
10091 - WSASYSNOTREADY, Network subsystem is unavailable.
· that the appropriate Windows Sockets DLL file is in the current path,
· that they are not trying to use more than one Windows Sockets implementation simultaneously. If there is more than one WINSOCK DLL on your system, be sure the first one in the path is appropriate for the network subsystem currently loaded.
· the Windows Sockets implementation documentation to be sure all necessary components are currently installed and configured correctly.
11002 - WSATRY_AGAIN, Non-authoritative host not found.
10092 - WSAVERNOTSUPPORTED, WINSOCK.DLL version out of range.
10094 - WSAEDISCON, Graceful shutdown in progress.
(OS dependent) - WSA_OPERATION_ABORTED, Overlapped operation aborted.
After a message has been retrived with either the GetMessage or the GetTop commands this property holds the From line from the header.
After a message has been retrived with either the GetMessage or the GetTop commands this property holds the header of the message.
If a message has a size less than 32768 bytes you will have the raw message here as well as in the temporary file (or the file/path you specify) given by the messagepath property.
Messagepath is the path to a temporary file used to hold a received message or multiple messages.
This temporary file is created on the fly if the property messagepath is empty when the getmail method is called.. If messagepath contains a path to a file that does not exist this file is created and the message is saved in the file. If messagepath points to a file which exists the message is saved at the end of this file with a blank line separating messages.
This property contains the Number of messages waiting on the POP server.
The IP address of the POP server on the form 184.108.40.206
You can obtain this address from a hostadress of the form mailhost.your.domain.com by using our control essock to resolve the address.
This property is persistent and is saved with your control so you can set it once and for all in the property window.
This property holds either the IP-address of the POP-server or the Internet name (including the domain) for the server. If you enter the name for the server EsPOP resolves the name to an IP-address. This resolved address is available in POPServerIP after it has been resolved. This takes place when a mail is sent.
The accepted form is thus either mailhost.somewhere.com and 220.127.116.11
This property replaces the old POPServerIP and from now on you should use POPServer property instead of the old POPServerIP property except for getting information about a resolved IP-address.
This property is persistent and is saved with your control so you can set it once and for all in the property window.
The password used to access a POP-account.
The Port property is normaly set to 110 the POP3 server port. By changing this value you have the possibility to use non standard ports.
After a message has been retrived with either the GetMessage or the GetTop commands this property holds the ReturnPath line from the header.
After a message has been retrived with either the GetMessage or the GetTop commands this property holds the Subject line from the header.
This is the Time-out, in milliseconds, used when receiving data from the POP-server.
After a message has been retrived with either the GetMessage or the GetTop commands this property holds the To line from the header.
This is the total size in bytes of all messages for the user on the POP-server.
If the received message is a MIME 1.0 message this property contains the Transfer Encoding for the message. See the content event for information on possible values.
The user name used to access a POP-account.
Delete mail with identifier index on the POP server.
Removes a temporary file typically created after a received message.
Use this method to check the content of a MIME message. Content events are fired for each part in the message. The return value are the number of parts in the message.
BOOL ExtractPart( long StartLine, LPCTSTR Path )
Use this method to extract the content from a MIME message. Information about content can be received with EnumContent and linenumber and content information is received in the Content event. The StartLine parameter is the line that starts the part. The Path parameter is the location for the extracted part.
The return value is true if the extract succed.
No decoding is done in this method. You should use our EsBase64 for instance to decode the result from this method into binary information.
BOOL GetMail(short index)
Retrieves mail with identifier index from the pop-server. Note that the first message has index=1. The message is saved in a temporary file. This temporary file is created on the fly if the property messagepath is empty. If messagepath contains a path to a file that does not exist this file is created and the message is saved in the file. If messagepath points to a file which exists the message is saved at the end of this file with a blank line separating messages.
The status events is triggered to give information about progress during the mail fetch.
With this function you can get the raw list of mailmessages waiting at the POP server as obtained by the LIST POP command. See also the method GetMailStatus which get the individual message size.
With this method you can get the output from the STATUS POP command. It is in its raw form as cnt totsize where cnt is equal to the number of messages and totsize is the total size of all messages available for the user.
long GetMessageSize(short index)
With this method you can get the size in bytes for a specific mail message.
Terminate a session with a POP server.
Connect to a POP server.
BOOL MessageToMailBody( LPCTSTR path )
With this method you can copy the body just received message to a new location specified by path.
Returns TRUE if the operation succeded.
BOOL MoveTempFile( LPCTSTR path )
With this method you can move the message just received to a new location specified by path.
Returns TRUE if the operation succeded.
Send the RESET POP command. If you have deleted messages on the server you now get access to them again.
This method issues the Top command to the POP server. The function of this command is the same as if a message is retrived as in the GetMail method with the important exception that only the first lines of the message is retrived.
A big differens between this method and the GetMail method is that there is never a temporary file created. The top of the message is only placed in the Message property. If the message is larger than the content of the Message Property the exceding part is truncated.
Note that the first message has index=1.
After a call to the EnumContent method content information in a mail is reported in this event.
Line - The line number for the start of this MIME part.
Notes on the Type parameter
Generic mixed set of types.
Do not decode message parts in this event. Just collect information and do the decoding later ehen the EnumContent method has returned.
Use our control EsBase64 to decode Base64 content and our EsQP control to decode Quoted Printable content.
Status gives progress information when certain operations is in progress. This can be useful when you need to inform a user about the progress and what is happening during lengthy operations. The progress is directly expressed is percentage of the task completed. A task is always started with an event where progress=0 and ended with an event where progress = 100. Getmail and Extract are methods which trigger this event.
This event gives response text from the server.
Where to get the control?
It is possible that you are reading this documentation without having access to the control itself. If you have Internet access you just need to connect to http://www.eurosource.se and fetch a fully working sample of the control. At this location you can also find samples on how to use the control.
We can email the control anywhere in the world if you send us a request to do so. Please state if you want MIME or BINHEX coding. Send request to firstname.lastname@example.org
If you use the unregistered version of the control a splash screen is displayed from time to time reminding you to register.To get rid of this nag-screen you need to register. Information is available at our site.
We ship anywhere in the world with World-wide First Class/Airmail if you select this option. The only media supported is 3.5" diskettes.The charge for this type of delivery is $15 (USD) extra.
We also check the newsgroup comp.lang.basic.visual.3rdparty on a regular basis and will try to help on all questions posted there.
How to contact us