mail to react on new incoming file by sending email to certain user.

i’ve been trying to make a script that checks a folder and if there is a new file the script should send a mail to a variable person with the filename in the subject? The person should be determined on a part of the filename which corresponds to a certain e-mail address.
example:
incoming file has file name 12345test.pdf So the subject of the mail should be “File 12345test.pdf is ready”
The body of the e-mail should be a fixed text. So not that important. The email adres should be looked by the script in a list. so 12345 is in the list email adress test@test.be.
the next file 02034 then should give a different email adress… and so on.
If anyone has any suggestions??? they would be very helpfull, i’am not sure if the way i think it should work is good so let me kow if there is an easier way to do this

I included what i got so far…

on adding folder items to this_folder after receiving added_items

try
tell application “Finder”
set the subject to the name of thisfile
end tell
set the item_count to the number of items in the added_items
end try
end adding folder items to
tell application “Mail”
set newMessage to make new outgoing message with properties {subject:thisfile as text, content:“Applescript says there is a file ready”}
tell newMessage
set visible to false
make new to recipient at end of to recipients with properties {name:“koen”, address:"koenlesage@hotmail.com"}
send
end tell
end tell

Model: ibook G4
AppleScript: 1.10.6
Browser: Safari 417.9.2
Operating System: Mac OS X (10.4)

Hi, i used the script that you posted and is indeed what i needed. thx very much for the help. The only thing that is still bothering me is that i notice that there is indeed something happening but the mail is not coming in. When there is a file copied into that folder finder reacts on it but no mail … any suggestions ?

Hi,
first of all thx for the help so far. The scrippt does indeed work when i use from the script editor. When I use as a script atached to a folder the finder flashes but nothing seems to happen. When i use the second script mail is launched and the email is send to the right address. When i try to do the same with the first script being a folder action then mail isn’t even booted. So not sure what the problem is but if you have any ideas?

Hi i checked and i did put the script in the folder you mention? I can add them when i go to folder actions on a folder. I tried with different scripts to make sure itsn’t my computer but the other scripts work just fine.
Any suggestions?