Thanks for the suggestions after some googling I am almost there. I think you are right David attaching a file to the currently selected message seems to be more stable, still need to work out some kinks.
Thanks mlgill that was a great starting point, since I have not used applescripts before (relatively new to osx), your suggestion helped a lot.