You could use CFSCHEDULE to create a task that regularly checks an email box using CFPOP and performs some action based on the content of the mail message(s) in the mail box.
1 person found this helpful
Yes this can be done, sort of. It cannot actually "trigger" an immediate action on ColdFusion's part, but you can have a scheduled CF task that runs on a regular basis (every 5 minutes, etc), to check the inbox. I received hundreds of emails per day containing data files from customers, and process them all with a CF task that periodically checks each of the inboxes for new mail.
Depending on the mail service you are dealing with, you have <CFPOP>, <CFEXCHANGE> (CF 8+), or <CFIMAP> (CF 9) to work with.
One of the tricky things is marking the messages you process so that you don't keep processing the same messages over and over. I have found that with CFEXCHANGE I can use the isRead flag to do this. I have an older script that uses an IMAP CFC that was available at the time, and with it I need to use the "deleted" flag for a message to mark that I've seen it.
You can use both the IMAP and EXCHANGE tags to work with MS Exchange servers, but if you use the IMAP tag then you need to be sure that the mailbox is setup for IMAP access. If you use the EXCHANGE tag then you need to be sure that the mailbox is setup for OWE access.
Hope this helps,
I've done some searching on google and yahoo to try to find examples of how to specifically check the inbox ("Depending on the mail service you are dealing with, you have <CFPOP>, <CFEXCHANGE> (CF 8+), or <CFIMAP> (CF 9) to work with.") but haven't found anything useful.
Can you please show me some pseudo code using cfpop let's say on how to check the inbox and then flag messages?
Take a look at the CF documentation. It includes sample code for checking a mail box with CFPOP.
What do you mean by "flag messages"?
If you're using POP, then there are a lot of examples (but a lot of them will look the same) in each version of Livedocs and each edition of CFWACK, as well as most of the other CF books running around. I'm pretty sure that one(which means it and all later editions) of the CFWACK editions has an example for building a simple POP-based mail client in CF.
POP is pretty simple. If you need access to boxes other than the Inbox, for example, you'll need IMAP/MAPI.
if I want only inbox folder mail, then which one is faster cfimap or cfpop?
Why don't you try them both and find out?
Ok. let me try both of it. Thanks