OK, I am having a bit of a brain lapse and need some help.
The following script watches a folder and sends an email when files are added. I cannot seem to remember how to have the repeat loop add more than one file in the email. Meaning 25 files are added to the folder, and only one email is generated listing all 25 files instead of creating 25 different emails.
on adding folder items to this_folder after receiving added_items
set curDate to (current date) as text
repeat with afile in added_items
set fileinfo to info for afile
set filename to name of fileinfo
tell application “Mail”
set this_message to make new outgoing message at beginning of outgoing messages
tell this_message
set visible to true
make new to recipient at beginning of to recipients ¬
with properties {address:“clindsey@yahoo.com”, «class rdsn»:“John Smith”}
set subject to “New Files Received”
set content to curDate & return & return & “The following files were received:” & return & filename
–send
end tell
end tell
end repeat
end adding folder items to
Thanks for your help!
I haven’t tested this, but I think you need to move your repeat…
(Write back if it doesn’t work.)
on adding folder items to this_folder after receiving added_items
tell application “Mail”
set this_message to make new outgoing message at beginning of outgoing messages
tell this_message
set visible to true
make new to recipient at beginning of to recipients ¬
with properties {address:“clindsey@yahoo.com”, «class rdsn»:“John Smith”}
set subject to “New Files Received”
set curDate to (current date) as text
repeat with afile in added_items
set fileinfo to info for afile
set filename to name of fileinfo
set content to curDate & return & return & “The following files were received:” & return & filename
end repeat
–send
end tell
end tell
end adding folder items to
No luck for me, I tried changing the location of the repeat loop also, but I am only receiving one file name…
on adding folder items to this_folder after receiving added_items
set curDate to (current date) as text
tell application "Mail"
set this_message to make new outgoing message at beginning of outgoing messages
tell this_message
set visible to true
make new to recipient at beginning of to recipients ¬
with properties {address:"clindsey@yahoo.com", «class rdsn»:"John Smith"}
set subject to "New Files Received"
repeat with afile in added_items
set fileinfo to info for afile
set filename to name of fileinfo
end repeat
set content to curDate & return & return & "The following files were received:" & return & filename
--send
end tell
end tell
end adding folder items to
any ideas?
thanks!
OK, I have no idea what I am doing wrong… Any ideas?
Thanks!