Trying to link email subject line and itunes

Well, this seems like a tough one to me. I already have a program that will execture certain actions if it reads a specific command in the suject line. Right now, if “music” is readin the subject line, then it will open iTunes and start playing at a specific location set in the script. I have two questions about this

  1. Is there a way to set the itunes song as a variable? That way I can have itunes play the playlist I wrote in the body of the email. Right now, it just plays the file I have set in the script.
  2. This is he tough part for me to see. The email checking program reads the suject line, and that triggers my events to happen. I have been controlling other applications with specific reponses in my email subjects. If I sent an email that said “all on”, I dont want it to search for the itunes playlist “all on” because that is command for another program I have. I tought it would be cool to have “music” in the subject line to activate itunes, and then have it read the body of the email gor the “name” of the playlist. Any ideas?

here is my initial idea…this is tough because it is a new world to me:

tell application “iTunes”
set bodyVar to “body of message”
set trackname to bodyVar
play playlist “trackname”
end tell