With DAQFactory you can also write script to retrieve emails. This could be used to allow you to change parameters in your system remotely through email. That said, it should be noted that email is not terribly secure, so you should never allow remote control of critical functions through email. Note that SSL is not supported (required by gmail). The POP3 features require more functions then variables. First the variables. You will typically set these once:
POP3.strServer: the name of your POP3 server. For example: POP3.strServer = "mail.myISP.com"
POP3.strUserName: your POP3 username
POP3.strPassword: your POP3 password (optional)
POP3.Port: set to the port of your POP3 server. Defaults to 110.
POP3.Timeout: the connection timeout in milliseconds. This defaults to 60000, or 60 seconds.
Once these variables are set, you can use these functions to actually retrieve your emails. In general you will want to Connect(), retrieve emails, then Disconnect().
POP3.Connect(): call this function first once your variables are set for the proper server. This function will connect to your server and retrieve the number of messages waiting. The function returns the number of messages waiting.
POP3.Disconnect(): when done, call this function to disconnect from the server.
Once you have connected and checked to see that their are messages, there four functions you can call on each individual message. Which message these functions apply is determined by the message number, which starts at 0 for the first message, and goes to 1 less than the number of messages returned by Connect().
POP3.RetrieveMessage(message number): retrieves the given message in its entirety. Use the Get...() functions listed below to retrieve the various parts of the message.
POP3.DeleteMessage(message number): deletes the specified message from the server.
POP3.RetrieveHeader(message number): retrieves just the header for the message. You can then use the Get...() functions listed below to retrieve the details. Obviously the GetMessageText() and GetBody() functions won't return anything since the body is not retrieved by this function.
POP3.RetrieveMessageSize(message number): returns the size, in bytes, of the specified message. Does not actually retrieve the message.
Once you have retrieved the message using RetrieveMessage() or RetrieveHeader() you can get the various parts of the message using these Get...() functions. They are pretty self explanatory:
POP3.GetBody()
POP3.GetCC()
POP3.GetDate()
POP3.GetFrom()
POP3.ReplyTo()
POP3.GetSubject()
POP3.GetTo()
These two functions are a little less obvious:
POP3.GetHeaderText(): gets the raw header text
POP3.GetMessageText(): gets the raw message text
Here's an example script that connects to a POP3 server, retrieves each message if the body size is less than 100,000 bytes, and deletes the message.
pop3.strServer = "mail.myserver.com"
pop3.strUserName = "me@myserver.com"
pop3.strPassword = "mypassword"
private count
private size
count = pop3.Connect()
? "found "+doubletostr(count)+ " messages..."
while (count > 0)
count--
size = pop3.RetrieveMessageSize(count)
if (size < 100000)
pop3.RetrieveMessage(count)
? pop3.GetBody()
endif
pop3.DeleteMessage(count)
endwhile
pop3.Disconnect()