Fetching URLs from email, downloading their contents

Hi Folks -

Very new to applescript (but not new to programming), and wondered if anyone had some advice.

I’m on a mail list from an individual who sends a lot of links via email to yousendit.com (a place for transferring large files)

So what I’d like to do is

  1. look for all mail from this one email address (which is also in a smart folder, if that’s useful)
  2. for each message, find the URL in it (that always begins with http://www.yousendit.com)
  3. open that url in safari
  4. follow the “Download Now” link on the YouSendIt page that opens
  5. click the link on the page that accesses the file on the second page (it’s one of those “if your download doesn’t beging automatically ‘click this link’” things)
  6. save the file to a location

I tried with automator, but couldn’t figure out a way to parse the URLs out of email messages.

Any help would be appreciated!

Thanks,
Matt

There are regular expression add-ins for Applescript, but if you’re a programmer, use a language you like for the parsing. I use PERL with “do shell script” for this. You don’t need to use safari for the download. Once you have the URL, you can curl it. (man curl in terminal for more information, or see posts on this site for lots of examples.) Then parse out the url on the button and curl that.

Feel free to post code if you run into trouble…