Find pictures and attach to e-mail

Hello all,

I’m trying to create a script that searches in a certain folder for any file of type JPEG i want to set this file as an attachment in application mail. If many of these files are found i want to set each picture a separate attachment in application mail.

this is what i came up with till now and it’s working…


tell application "Mail"
set theSubject to "this is a smaple subject"
set theBody to "this is a sample body.."
set theAttachment to "psychoed HD:testfolder:"
	set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
	tell newMessage
		set visible to true
		make new to recipient at end of to recipients with properties {name:"", address:""}
		tell content
			make new attachment with properties {file name:theAttachment} at after the last paragraph
		end tell
	end tell
	activate
end tell

now all i need to do is check the testfolder for jpegs, and attach them each seperatly by using the same command but in some sort of a loop.

i need help urgently, I’m new with these stuff…

Any help would be greatly appreciated,

Thanks,

Psycho-ed

thanks a lot jacques, the script u gave me worked perfectly.
but when i tryied to implement the same thing on entourage i had a problem… this was what i did


set theSubject to "this is a test subject"
set theBody to "this is a test body"
set theAttachment to "Psychoed HD:Users:psychoed:Desktop:test"
set theAttachment to theAttachment & ":Resources"
tell application "Finder" to set theAttachments to files in alias theAttachment whose file type is "JPEG"
tell application "Microsoft Entourage"
	set newMessage to make new outgoing message at outbox folder with properties {subject:theSubject, content:theBody}
	tell newMessage
		repeat with i in theAttachments
			make new attachment with properties {file:i as alias}
		end repeat
	end tell
	activate
end tell

when i run this script i get an Error that says “Microsof Entourage got an error: Can’t make class attachment.” can you guys please help me fix this?

and again thanks a lot jacques for the last post,

Regards,
Psycho-ed