I have a security camera that takes pictures based on motion in our store. I have the camera put the pictures into a pictures folder on our OS X.4 Server. I would like to have any pictures that are added to the folder between the hours of 5:00 pm and 7:00 am emailed to me so I have a record remotely if anyone enters the store after we are closed.
I know you can get object information on individual files, but am not sure how I would select the file to be mailed. Does anyone have an example script that does some sort of similar use that I can look at?
you can do this with a folder action and this example script.
Replace the lines which set theAddress and theName with your data.
The subject of the mail is “Picture” and the date when the picture has been added to the folder,
you can change this too, if you like.
on adding folder items to this_folder after receiving these_items
if hours of (current date) > 6 and hours of (current date) < 18 then
repeat with myFile in these_items
set theAddress to "janedoe@example.com"
set theName to "Jane Doe"
set theSubject to ("Picture " & (current date) as string)
set theAttachment to myFile
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content:((current date) as string) & return & return}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
tell content to make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
activate
send newMessage
end tell
end repeat
-- tell application "Mail" to quit -- if Mail should launch and quit every time
end if
end adding folder items to