2

Is there a way to say "I want to get an email update when an answer is posted to this question" (that is, to someone else's question)? Right now, the only thing I can see to do is to tag it as a favorite so it's easy to check back now and again.

| |
2

As it turns out, there is not a way to have SE let you know by email immediately when an answer is posted to a question, but I have written (not really super proud of this yet but it works) a grep tool where you can paste the URL to the question, the frequency that you want Mathematica to check, and the number of times you want Mathematica to keep checking. Although it aborts well on discovery of a new answer, as well as manually, it seems sort of trashy to me to not have a nicer abort button than "Evaluation->Abort Evaluation", or "Alt +".

The grep does export then import to and from a flat file on your default local.

Anyway, here is my code, feel free to improve:

Set link to the URL of the post.

Set cnum to the current number of answers (default 0).

Set checktimer to the frequency that you wish to probe this site in seconds (careful here, don't slam SE).

Set stopcheck to the number of times you you wish to probe.

All is currently set to every 5 minutes (300 seconds) for 1 hour.

grep[file_, patt_] := 
With[{data = Import[file, "Lines"]}, 
Pick[Transpose[{Range[Length[data]], data}], 
StringFreeQ[data, patt], False]]

link = "http://meta.mathematica.stackexchange.com/questions/1293/get-notified-of-answers-to-a-question";
cnum = 0; (*current number of posts*)
checktimer = 300; (*check every number of seconds*)
stopcheck = 12;(*stop the loop after stop multiplied by checktimer seconds*)

The grep function should seem pretty clear, I used it in the past scraping data from web sites (probably ripped it off somewhere long ago).

Here is the implementation:

For[i = 1, i <= stopcheck, i++,
Pause[checktimer];(*seconds*)
Export["segrep.txt", Import[link, "Plaintext"]];
If[Length[grep["segrep.txt", {"improve this answer"}]] > cnum,
SendMail[
"To" -> "your-inbound-email@icloud.com",
"Subject" -> "Stackexchange!",
"Body" -> "You have a new Mathematica answer on stackexchange!",
"From" -> "your-outbound-email@gmail.com",
"Server" -> "smtp.gmail.com",
"UserName" -> "your-outbound-email@gmail.com",
"Password" -> "your-outbound-password",(*<<<---Needs Password, else add in prompt*)
"PortNumber" -> 587,
"EncryptionProtocol" -> "StartTLS"];
Abort[];
]
]

You clearly need to put your two email addresses and password inside the quotes correctly. If you use a gmail outbound to your phone email push, then the rest will probably work as is (otherwise alter).

Change the URL, and change checktimer and cnum to some small numbers for your test. Don't slam the site.

P.S. The hardest part of this was finding the distinguishing difference between a question with n versus n+1 answers in any SE community. It turned out that grepping "improve this answer" did the trick.

On to the final test...

| |
  • Thanks. I guess that's best practice as of now...but really not optimal! – rogerl May 9 '14 at 20:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .