Sunday, February 26, 2012

SENDING TO EVERYONE. PASS IT ON.

I think I need to create a script that

1. Scans my gmail inbox for any mail whose subject line uses ALL CAPS and which urges me to forward it to everyone I know;
2. Searches snopes.com for the message body;
3. Replies with a link to the top Snopes hit and its text, plus a preachy little sermon by me on the importance of Truth

... all automatically.

What sort of tools can I use to make such a script?

If you don't know, please forward my question on to everyone you know. It's very important. It probably involves President Obama and/or dead babies.

3 comments:

Anonymous said...

Well... Gmail supports IMAP access...

So something like:

server = imaplib.IMAP4('gmail.com')
server.login(login, passwd)
server.select('INBOX')
typ, data = server.uid('search', 'ALL')

for uid in data[0].split():
  typ, fetch = server.uid('fetch', uid, '(RFC822)')
  body = fetch[0][1]
  msg = email.message_from_string(body)
  print 'Subject:', msg.get('Subject')

That's a start, then you just need to send the message.

Does that help any?

Sean

Unknown said...

Thanks, Sean! When I can get to it in a couple weeks, I'll list you as a co-author on LetMeSnopesThatForYou.

Anonymous said...

Excellent problem reduction. Now if I could only get Aunt Gertie to do it...:-)