Repeating with different variables

Hey, I’m currently making a script and I have a bit that repeats, however, when it repeats, I want the variable to change each time. I don’t know how to do this so I would be grateful if you could tell me how to do this.

This is the script


set search_test1 to "test5"
			
			set search_test2 to "test"

			set search_test3 to "test7"

			set search_test4 to "test9"

repeat with eachMessage in theMessages
		tell application "Mail"
			
			
			tell eachMessage to set {theSender, theAddress, theSubject} to {extract name from sender, extract address from sender, subject}
			set newMessage to make new outgoing message with properties {subject:"asw", content:search_test1, visible:true}
			tell newMessage
				make new to recipient at end of to recipients with properties {name:theSender, address:theAddress}
			end tell
			activate
		end tell
	end repeat

I want the search_test1 variable to change to search_test2 the next time it repeats, search_test3 the next time and so on.

If you could help that would be great.

Thanks.

Hi,

assuming the number of messages is the same as the different searches, try this


set searchList to {"test5", "test", "test7", "test9"}
repeat with eachMessage from 1 to count theMessages
	tell application "Mail"
		tell (item eachMessage of theMessages) to set {theSender, theAddress, theSubject} to {extract name from sender, extract address from sender, subject}
		set newMessage to make new outgoing message with properties {subject:"Xbox Live", content:item eachMessage of searchList, visible:true}
		tell newMessage
			make new to recipient at end of to recipients with properties {name:theSender, address:theAddress}
		end tell
		activate
	end tell
end repeat