Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

How do you check for new emails?

 [1/4] from: kimm2::mcmaster::ca at: 3-Oct-2002 14:33


I'm familiar with sending out emails via REBOL. I have seen some good examples of checking the inbox and retrieving mail. I basically want my phone to notify me through a text message if I get a new email in my inbox. Is there a flag in each email that lets you see if it's been "read"? I want to the code to frequenty log in, check for "new emails" that have arrived since I've last checked, and if so, send out an email to my phone with only the "from" and "subject". I already know how to do the latter. Thanks! Matt

 [2/4] from: greggirwin:mindspring at: 3-Oct-2002 14:11


Hi Matt, << Is there a flag in each email that lets you see if it's been "read"? I want to the code to frequenty log in, check for "new emails" that have arrived since I've last checked, and if so, send out an email to my phone with only the "from" and "subject". I already know how to do the latter. >> If your code is doing the checking, then it just needs to know the last time it checked to see if anything new has arrived (based on the most recent timestamp of the incoming messages). Not being a mail expert, I can't tell you how reliable this mechanism will be, but it might work well. You could also maintain a limited FIFO list of message IDs and filter out messages based on that. I.e. if a new message has an ID that's in the list, you've seen it already. --Gregg

 [3/4] from: gchiu:compkarori at: 4-Oct-2002 10:54


>I basically want my phone to notify me through a text >message if I get a >new email in my inbox. > >Is there a flag in each email that lets you see if it's >been "read"? I
Mail clients use the UIDL command to retrieve the unique message id to see if they have read the message or not. Rebol's POP protocol doesn't do this. But you can fudge it. Jeff @ Rebol wrote a modified POP protocol that allows you to send the TOP command. This means that you can grab all the headers ( including subject, from, and message id ) when you open up the mailbox without having to read the message bodies. You can then parse out the message ids, and then only retrieve the subject/from details as you need. You will need to track the message ids though. Here's his post again ( it's hard to find on Escribe ) Jeff (jeff from rebol.com) wrote: Well, that's pretty simple. It would be a little more difficult to have a different refinement for read with pop-- but pop can pretty easily be modified to return the top info, or store the info similarly to the way we had the LIST command do it. Perhaps the URL could be a little different: x: open pop://user:[pass--server]/summary Will cause x/locals to get a field that contains the TOP info. Of course, its up to you to parse the TOP info afterwards. So... change the number in top-check block to how ever many lines of context you want. Here you go: ------------------------------------------------------- REBOL [ Title: "A slightly modified version of pop" ] make Root-Protocol [ {Communicate with POP. This protocol is block oriented not string oriented.} port-flags: system/standard/port-flags/pass-thru open-check: [ ; port is bound to confirm frame none "+OK" ["USER" port/user] "+OK" ["PASS" port/pass] "+OK" ] close-check: ["QUIT" "+OK"] write-check: [none "+OK"] stat-check: ["STAT" "+OK"] list-check: ["LIST" "+OK"] top-check: [reform ["TOP" num 10] "+OK"] open: func [port /total/tblock/summary][ open-proto port port/state/tail: second total: load net-utils/confirm port/sub-port stat-check port/locals: make object! [ total-size: third total net-utils/confirm port/sub-port list-check sizes: load read-til-dot port make string! 100 summary: either port/target summary [ tblock: system/words/copy [] repeat num port/state/tail [ net-utils/confirm port/sub-port reduce bind top-check 'num append tblock read-til-dot port make string! 100 ] tblock ][none] msg-nums: make block! port/state/tail repeat n port/state/tail [append msg-nums n] ; lookaside index ] port/state/index: 0 ; a zero based index ] read-til-dot: func [port buf][ while [(line: system/words/pick port/sub-port 1) <> "."] [ insert tail buf line insert tail buf newline ] buf ] read-message: func [ "Read a message from the POP server" port n [integer!] /local buf line ][ insert port/sub-port reform [ "RETR" system/words/pick port/locals/msg-nums port/state/index + n] net-utils/confirm port/sub-port write-check read-til-dot port buf: make string! 1024 ; guess at size ] pick: func [ "Read the Nth message from the POP port" port ][ read-message port 1 ] copy: func [ "Copy a set of messages into a block" port /local msgs n ][ msgs: make block! port/state/num repeat n port/state/num [ append msgs read-message port n ] msgs ] remove: func [ "Remove the current message" port ][ while [ port/state/num > 0 ][ insert port/sub-port reform [ "DELE" system/words/pick port/locals/msg-nums port/state/index + 1] net-utils/confirm port/sub-port write-check system/words/remove at port/locals/msg-nums port/state/index + 1 port/state/tail: port/state/tail - 1 port/state/num: port/state/num - 1 ] port ] net-utils/net-install POP self 110 ] -- Graham Chiu

 [4/4] from: johkje-7:sm:luth:se at: 7-Oct-2002 21:43


Late response. But if you still haven't got the answser:
>Is there a flag in each email that lets you see if it's been "read"?
There is a field in the header that it set the first time a mail is read: Status: RO Don't know if it's the same on all mailservers. But it works for me atleast. / John