ReadEmails |
||
Aptilis 2 |
ReadEmails(destinationArray[], POP_Server, UserName, Password[[[, PleaseSave], LeaveOnServer], GetHeadersOnly])
ReadEmails uses the POP3 protocol to retrieve e-mails
from a mailserver.
It will retrieve all the e-mails available, store them
in an array (destinationArray[]) and erase them from the server.
So you'd better save them before ending the Aptilis
program.
The next three parameter are optional:
PleaseSave: If specified and different from 0
will cause ReadEmails to do a backup of the e-mails fetched on
your hard drive in the current directory (named 1.mail, 2.mail etc.), but be warned,
that successive calls to ReadEmails may overwrite those backups.
LeaveOnServer: If different from 0, e-mails will not be deleted from the server. Please note: If you execute ReadEmails again, you will get the same messages! (since build 045d)
GetHeadersOnly: If different from 0, only the e-mail headers will be returned. If larger than 1, then the first n-1 lines of the e-mail will be returned also. (since build 045d)
Return value:
0 if everything went well or -1 in case of error, in which case
_errno may contain additional details about the error.
Example:
userName = "you@some_address.com" $ password = "I_am_not_telling_you" $ pop3server = "pop3.some.server.com" $ print("Now starting to read e-mails\n") // get all mails, make no backups and delete them from the server r = readEmails(messages[], pop3server$, userName$, password$) print("r=", r$, "\n") print("_errno=", _errno$, "\n") n = getArraySize(messages[]) for i=0 to n - 1 // store the mails in subfolder 'mails' saveFile("mails\\" + int(i + 1) + "-mail.txt" $, messages[i]$) end for
See also: sendMail, setSMTPSever.