A tiny question about this Mail script... shouldn't take a sec....

Hello all

I have an auto-responder (of sorts) set up via a Rule which runs an Applescript when i receive an email that meets the criteria. Basically its to automatically send an email when i am paid for an item via paypal.

The script is here:

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			repeat with eachMessage in theMessages
				set theName to extract name from sender of eachMessage
				if exists reply to of eachMessage then
					set theAddress to reply to of eachMessage
				else
					set theAddress to extract address from sender of eachMessage
				end if
				set newMessage to make new outgoing message
				tell newMessage
					make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
					set visible to false
					set subject to "SUBJECT OF EMAIL"
					set content to "CONTENTS OF EMAIL"
				end tell
				send newMessage
				tell eachMessage
					set was replied to to true
				end tell
			end repeat
		end tell
	end perform mail action with messages
end using terms from

It works rather well.

I have the rule set up to only pick up emails on ONE of my accounts (my paypal email account, which makes sense). I obviously want it to reply WITH this account also (theres no point in receiving their notification of payment, then replying with my .mac account for example).

When testing it just now, it seemed to pick an account at random, and sent it with my .mac account, even though it was replying to an email in my googlemail account, as specified by the rule. Then when i tested it again, it used my googlemail account. it’s rather wierd.

Is there a way to alter the script to FORCE it to reply with the googlemail account?
And whilst I’m here can it be streamlined in anyway?

Many, many thanks everyone.

To specify the account you want to set, I believe, the Sender field as it appears in the account drop down of a new message… so it should be “First Last ”

Here’s a snippet from apple to return a list of eligible senders…

tell application "Mail"
	set listOfSenders to {}
	set everyAccount to every account
	repeat with eachAccount in everyAccount
		set everyEmailAddress to email addresses of eachAccount
		if (everyEmailAddress is not equal to missing value) then
			repeat with eachEmailAddress in everyEmailAddress
				set listOfSenders to listOfSenders & {(full name of eachAccount & " <" & eachEmailAddress & ">") as string}
			end repeat
		end if
	end repeat
end tell

And here is a shorter version of your new message block…

set newMessage to make new outgoing message with properties {subject:"SUBJECT OF EMAIL", sender:theSender, content:"CONTENTS OF EMAIL", visible:true}
	tell newMessage to make new to recipient at end of to recipients with properties {name:theName, address:theAddress}

Thanks for your reply James.

Any chance you could show me how to implement those snippets into what I have already? I’m by no means an expert. It’d be a great help!

Cheers