This script here is not doing what I want it to do
tell application "Finder"
set selectedFolder to choose folder
set fileList to items of selectedFolder
repeat with i from 1 to (count of fileList)
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"Your File", content:"is attached."}
tell newMessage
make new to recipient with properties {address:"bob@spambob.com"}
end tell
try
make new attachment with properties {file name:currentFile} at after the last paragraph
end try
send newMessage
end tell
delay 60
end repeat
end tell
it should send file 1 of 2 in choosen folder and send and delay 60
then send file 2 of 2 in choosen folder and send and delay 60
but its not sending any attachments, it sends the correct amount of email but not attachments.
whats wrong?
the end tell of tell newMessage must be after creating the attachment.
The try block avoids any error message, so for testing it’s better to remove it.
The variable currentFile is not defined
tell application "Finder"
set selectedFolder to choose folder
set fileList to items of selectedFolder
repeat with i from 1 to (count of fileList)
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"Your File", content:"is attached."}
tell newMessage
set visible to true
make new to recipient with properties {address:"bob@spambob.com"}
-- try
make new attachment with properties {file name:currentFile} at after the last paragraph of content
-- end try
end tell
activate
send newMessage
end tell
delay 60
end repeat
end tell
Ciao,
without the try block your script would not even have compiled in ScriptEditor because you forgot to declare the variable currentFile. This should work:
tell application "Finder"
set selectedFolder to choose folder
set fileList to items of selectedFolder
repeat with i from 1 to (count of fileList)
set currentFile to item i of fileList as alias
tell application "Mail"
set newMessage to (make new outgoing message at end of outgoing messages with properties {subject:"Your File", content:"is attached.", visible:true})
tell newMessage to make new to recipient with properties {address:"peterpan@nowhere.it"}
tell content of newMessage
make new attachment with properties {file name:currentFile} at after last word
end tell
send newMessage
end tell
delay 5
end repeat
end tell
I changed the delay to 5 because I did not want to wait - I guess it is not necessary at all…
HMMM this script attaches the attachment to message but i get mail error saying “You have not specified any recipients.” What is wrong now, does applescript hate me???
tell application “Finder”
set selectedFolder to choose folder
set fileList to items of selectedFolder
repeat with i from 1 to (count of fileList)
set currentFile to item i of fileList as alias
tell application “Mail”
set newMessage to make new outgoing message with properties {subject:“Your File”, content:“is attached.”}
tell newMessage
set visible to true
make new to recipient with properties {address:“bob@spambob.com”}
– try
make new attachment with properties {file name:currentFile} at after the last paragraph of content
– end try
end tell
activate
send newMessage
end tell
delay 60
end repeat
end tell
tell application "Finder"
set selectedFolder to choose folder
set fileList to items of selectedFolder
repeat with i from 1 to (count of fileList)
set currentFile to item i of fileList as alias
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"Your File", content:"is attached."}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {address:"bob@spambob.com"}
make new attachment with properties {file name:currentFile} at after the last paragraph of content
end tell
activate
send newMessage
end tell
delay 60
end repeat
end tell
Looks like - here everything ok, either with your version either with mine …
Try to recopy the code completely from this page and recompile your script.
Annoyingly the script works. … as I found out when I ran it forgetting to comment out the send… Doh
Hope you like the picture… and glad I choose a none important folder. ( Note to self, do not test scripts before fist cup of coffee of the day)
Yeah well annoyingly that script doesn’t work for me, which is bs
yall says it works yet when i retype character for character
line for line
word for word
Iget You have not specified any recipients.
even when recopied
it seems like this line never gets passed to mail
make new to recipient at end of to recipients with properties {address:“bob@spambob.com”}
which results in the mail error You have not specified any recipients.
So I give up, I have unhappily wasted my time wiht applescript trying to get scripts to work,
Thanks apple for jewing me out of using applescript and maing it run for everybody else, thanks
Noting that you have been banned VT, I’ll post the explanation:
An AppleScript application can be written to do really evil things to the machine running it. MacScripter simply can not and will not allow authors to upload scripts to our servers or to link to binaries of them on external severs if we don’t know exactly who the author is. In fact, there is enacted and some pending legislation (HIPAA, FACTA and Gramm-Leach-Bliley {GBL}) that apply to MacScripter, LLC, so we have to be cautious or we will be liable.
Rather than trying to hide your name, you are encouraged to use a non-revealing user name and that is all visitors to ScriptBuilders will ever see. Your real name is never available to the public {or sold to others}, nor is your true email address exposed. If a user wishes to contact you directly they can do so from the links on the scripts info page.