using terms from application "Mail"
on perform mail action with messages selectedMessages for rule theRule
tell application "Mail"
set selectedMsgs to selection
repeat with msg in selectedMsgs
set theSubject to subject of msg
set theSender to extract name from sender of msg
set theAddress to extract address from sender of msg
set theDate to date sent of msg
set nowDate to current date
set theBody to "Uw bericht" & return & return & "Onderwerp: " & theSubject & return & "Verstuurd: " & theDate & return & return & "is ontvangen op " & nowDate & ".
Met vriendelijke groet,
Van Hooren drukkerij en repro bv
" & return
set newMessage to make new outgoing message with properties {subject:"Ontvangstbevestiging: " & theSubject, content:theBody & return & return}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {name:theSender, address:theAddress}
end tell
send newMessage
end repeat
end tell
end perform mail action with messages
end using terms from