Applescript Mail Rule Help

Discussion in 'Mac Programming' started by drivebyed, Sep 22, 2010.

  1. macrumors newbie

    drivebyed

    Joined:
    Sep 22, 2010
    Location:
    London, UK
    #1
    Hi All,

    Bit new here and my coding is ropey at best. Basically ive got some automated emails that appear in my inbox every 10 mins or so. They have the same subject but different contents. What I want to do is, when the emails come in to take the first line of it then send a new email with the first line as the subject.

    So what ive done is to write an applescript which gets triggered on a subject line rule. The script is as follows:

    Code:
    using terms from application "Mail"
    	on perform mail action with messages theMessages for rule theRule
    		set recipientAddress to "example@com.com"
    		tell application "Mail"
    			repeat with thisMessage in theMessages
    				set theText to paragraph 1 of content of theMessage
    				set theNewSubject to "!-- some text --!" & theText
    				set theNewMessage to make new outgoing message
    				tell theNewMessage
    					make new to recipient at end of to recipients with properties {address:recipientAddress}
    					set subjext to theNewSubject
    					set content to theText
    				end tell
    				delay 5
    				send theNewMessage
    				tell thisMessage
    					set replied to true
    				end tell
    			end repeat
    		end tell
    	end perform mail action with messages
    end using terms from
    Any help would be much appreciated. As i said earlier not even registering in the console and nothing seems to happen.

    Thanks.
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
  3. thread starter macrumors newbie

    drivebyed

    Joined:
    Sep 22, 2010
    Location:
    London, UK
    #3
    I put the script you linked into the rule and the rule is defiantly triggering. It doesnt then seem to be executing my script. I am going to try putting the script you linked into mine and see if it still triggers.

    Thanks
     
  4. thread starter macrumors newbie

    drivebyed

    Joined:
    Sep 22, 2010
    Location:
    London, UK
    #4
    Okay after some testing it looks like
    Code:
    paragraph 1 of content
    is no longer supported and is breaking the script - is there an alternative? This is really the most important part.
     

Share This Page