*WEB/POP3 |
POP3 Email Retrieval |
This object provides a means to connect to a POP3 email server and retrieve email. It can be used against any POP3 email server using either an encrypted or unencrypted connection.
The supported Methods and Properties are listed below.
(The *web/pop3 object was added in PxPlus 2014.)
Connect to the desired server using either the 'Connect or 'SSLConnect method, providing the POP3 server name, user ID and password. By default, the process will connect with the default POP3 port numbers (110 for non-SSL, 995 for SSL). If you want to use a different port, append the port number to the server name, separated by a ; (semi-colon); e.g. 'pop.example.com;1234'.
During the connection sequence, the object will download a list of the emails and their identifiers from the server. The number of emails on the server can be found in the 'MailCount property. You can also retrieve the server's internal mail identifier using the 'GetMailId$(mailidx) method.
To get the contents of an email, use the 'Retrieve method, passing either the mail index or the server mail identifier.
Once it is retrieved, you can access the email 'Subject$, 'From$, 'Header$ and 'Body$.
To delete an email from the server, use the 'Delete method. It will delete the current email retrieved.
Processed Emails
The object also provides a means to record "Processed" emails. You can supply a file that can be loaded with the identifiers of emails your logic has processed.
The following methods are supported:
Method |
Description |
Connect(srvr$,userid$,password$) |
Connect to mail server (non-encrypted). |
SSLConnect(srvr$,userid$,password$) |
Connect to mail server (encrypted). |
Disconnect( ) |
Disconnect from server. |
GetMailId$(mailidx) |
Return identifier for specified index. |
Retrieve(mailidx) |
Get specific mail given index. |
Retrieve(mailid$) |
Get specific mail given mail identifier. |
IsProcessed( ) |
Returns 1 if current email has been marked as processed; else returns 0. |
MarkProcessed( ) |
Mark current email as processed. |
Retrieve( ) |
Get next unprocessed email. |
Delete( ) |
Delete currently selected email. |
LoadProcessed(filename$) |
Load file containing list of processed emails. |
SaveProcessed(filename$) |
Save list of currently processed emails. |
The following properties are supported:
Property |
Description |
MailCount |
(Read Only) Number of emails on server. |
Header$ |
(Read Only) Returns the email header for the currently selected email. |
Body$ |
(Read Only) Returns the body of the currently selected email. |
From$ |
(Read Only) Returns the from address for the currently selected email. |
Subject$ |
(Read Only) Returns the subject line for the currently selected email. |
Mailid$ |
(Read Only) Returns the internal message ID for the current email. |
Mailid |
(Read Only) Returns the index number for the current email (reset on Retrieve). |
LastError$ |
(Read Only) Last error code. |
IsSecure |
(Read Only) Returns 1 if using an encrypted connection, 0 if not. |
IsConnected |
(Read Only) Returns 1 if connected, 0 if not. |
oPop=new("*web/pop3" for program)
sts=oPop'Connect("pop3.example.com","test@example.com","SnowFlakes")
if sts<>1 \
then print oPop'LastError$;
end
print oPop'MailCount
!
for i=1 to 20
print oPop'GetMailId$(i,err=*break)
next
!
for i=1 to 5
oPop'Retrieve(i)
print "Subject:",oPop'Subject$
next i
oPop'Disconnect()