Sending email every half hour

i want this script to send an email every half hour i have no idea how to do that
here is my so far failed script

tell app "mail"
set newMessage to make new outgoing message with properties {subject: "Get David a MAC!!!", content:"Get david a mac or these emails wont stop!"}
			make new to recipient at end of to recipients with properties {name: "Linda�, address: davidmzio.com}
			send
		end set
	end set
end tell

This should do it. Save it as a stay open application and then launch it. It will repeat every 30 minutes.

on idle
	tell application "Mail"
		set newMessage to make new outgoing message with properties {subject:"Get David a MAC!!!", content:"Get david a mac or these emails wont stop!"}
		tell newMessage
			make new to recipient at end of to recipients with properties {name:"Linda", address:"davidmom@cruzio.com"}
		end tell
		set visible of newMessage to true
		send newMessage
	end tell
	return (30 * minutes)
end idle

– Rob

it starts, does nothing, then quits. changed it a little because the person i am sending to has two email addresses


set EmailList to {"uzio.com", "Lljhahoo.com"}
set EmailTo to item (random number from 1 to (length of EmailList)) of EmailList
on idle
	tell application "Mail"
		set newMessage to make new outgoing message with properties {subject:"Get David a MAC!!!", content:"Get david a mac or these emails wont stop!"}
		tell newMessage
			make new to recipient at end of to recipients with properties {name:"Linda", address:"& EmailTo& "}
		end tell
		set visible of newMessage to true
		send newMessage
	end tell
	return (30 * minutes)
end idle

When you saved the script as an application, did you select “Stay Open” in the save dialog?

– Rob

i didnt know about that…

Did it help? I guess you missed where I said “Save it as a stay open application” when the script was offered. :slight_smile:

– Rob

it works now, but i cant get the variables to work so it says different things every time

That’s because your code to set the random address is outside of the idle block:

on idle
	tell application "Mail"
		set newMessage to make new outgoing message with properties {subject:"Get David a MAC!!!", content:"Get david a mac or these emails wont stop!"}
		tell newMessage
			make new to recipient at end of to recipients with properties {name:"Linda", address:(some item of {"address1@domain1.com", "address2@domain2.com"})}
		end tell
		set visible of newMessage to true
		send newMessage
	end tell
	return (30 * minutes)
end idle

Jon

This should work, although random doesn’t necessarily guarantee that it will be different every time. The result will be random, not predictable.

on idle
	set EmailList to {"davidmom@cruzio.com", "Lljh2001@yahoo.com"}
	set EmailTo to item (random number from 1 to (length of EmailList)) of EmailList
	
	tell application "Mail"
		set newMessage to make new outgoing message with properties {subject:"Get David a MAC!!!", content:"Get david a mac or these emails wont stop!"}
		tell newMessage
			make new to recipient at end of to recipients with properties {name:"Linda", address:EmailTo}
		end tell
		set visible of newMessage to true
		send newMessage
	end tell
	return (30 * minutes)
end idle

– Rob

its all good now, and yes the checking the keepp running thing worked
thanks :smiley: :smiley: :smiley: :slight_smile: :smiley:

nevermind. how come this gets an error that says c=variable subjectto is not defined?


set EmailList to {"daviio.com", "Lljoo.com"}
set EmailTo to item (random number from 1 to (length of EmailList)) of EmailList
set MessageList to {"go to xvsxp.com to see how superior the MAC is to the PC", "PCs are more expensive then Macs, and PCs crash, Macs don't crash.", "Get David a Mac or these Emails won't stop", "MACs let me send all these emails without writing them all!", "David needs a MAC!"}
set MessageTo to item (random number from 1 to (length of MessageList)) of MessageList
set subjectList to {"Get David a MAC", "David needs a MAC", "MACs are better", "PCs are horrible", "david deserves a MAC", "PCs=Not good, MACs=best", "Panther is the best OS in the world!! XP is really not all that good"}
set Subjectto to item (random number from 1 to (length of subjectList)) of subjectList
on idle
	tell application "Mail"
		activate
		set newMessage to make new outgoing message with properties {subject:"" & Subjectto & "", content:"" & MessageTo & ""}
		tell newMessage
			make new to recipient at end of to recipients with properties {name:"Linda", address:"" & EmailTo & ""}
		end tell
		set visible of newMessage to true
		send newMessage
	end tell
	return (30 * minutes)
end idle

Did you not read the posts above?

Jon

it probably doesn’t matter now, but would you be so kind as to edit the email adresses i accidently put in my post out of yours? thanks