rule triggered applescript

Discussion in 'Mac Programming' started by Scaldy, Nov 1, 2009.

  1. Scaldy macrumors newbie

    Nov 1, 2009
    I'm aware that using these rule driven applescripts aren't the greatest of ideas since they could potentially allow someone to activate the rule that wasn't originally intended, but what I want to do isn't very dangerous.

    I have some experience using applescripts, but this just seems out of my league.

    My goal is to send myself a mail via my phone to my home mac, have that mail trigger a rule which then copies the text in the body of the mail, then appends the copied text to a .txt file, saves it, and closes.

    My endgame here is to be able to send myself an email to add an item to my todo list and update it on the fly. I've considered using other services to get this done, but I'm trying to preserve the way I'm doing it on my computer normally while integrating the "on-the-go" updates.

    Any help would be appreciated.


    After some more thought, if the applescript could be triggered from receiving an adium message from a specific screen name... that would work too.
  2. robbietherobot macrumors newbie

    Oct 12, 2005
    Smash and Grab

    It's a bit ropey but this should do the trick!

    Basically you should set a rule that when Mail receives a message with "AddToDo" as a subject line fire up this AppleScript, it adds the body of your message to a given text file.

    Should get you started anyway!
    set ToDoDoc to "Macintosh HD:Users:yourusername: Desktop:ToDoItems.rtf" --Path to your document
    set SubjectFlag to "AddToDo" -- unique Subject Line to add to

    set ToDoItem to ""

    tell application "Mail"
    tell (first message of inbox whose subject is SubjectFlag) to if exists then
    set ToDoItem to first paragraph of (get content) as text
    end if
    end try
    --return ToDoItem
    end tell

    tell application "TextEdit"

    open ToDoDoc
    set paragraph 1 of document 1 to ToDoItem & return & paragraph 1 of document 1
    save document 1
    close document 1
    end tell
  3. Scaldy thread starter macrumors newbie

    Nov 1, 2009
    Thanks for the reply, I'll try it out and see how it goes.

Share This Page