Copy an email from Mail.app

I am using a rule to create a new email based on the original email that triggered the rule. I have managed to pretty well do this except I cannot work out how to attach the existing attachment to the new mail. The below is what I have so far… it works if I don’t try to add the attachment but as soon as I try to add the attachment to the new email it fails. Any help much appreciated I have been trying for ages with no success.

using terms from application “Mail”
on perform mail action with messages theMessages for rule theRule
tell application “Mail”
repeat with eachMessage in theMessages
set theAttachment to item 1 of mail attachments of eachMessage
set newMessage to make new outgoing message with properties {subject:“New Subject”, content:“Blah Blah” & return & return}
tell newMessage
set sender to “sender@somewhere.co.uk
make new to recipient at end of to recipients with properties {name:“Recipient”, address:"recipient@mac.com"}
make new attachment at end of content with theAttachment
end tell
send newMessage
end repeat
end tell
end perform mail action with messages
end using terms from

What’s the class of theAttachment after you assign it? I’m not sure you can reference them that way. You might have to download the document and then attach that to your new message.

Can you tell us what the event looks like and what error you’re getting? You’ll need a test to skip this step if there’s no attachment or to loop if there are multiple attachments.