Hi! My goal is to create a Dropzone action that will automatically send an email with the dropped file to a person with no interaction on my part. I wrote an applescript that works, but I can't seem to incorporate it into Dropzone.
Here's my stab at the Dropzone script:
# Dropzone Action Info
# Name: Email File to Person
# Description: Emails a file to a person. Multiple files will be zipped.
# Handles: Files
# Creator: Aptonic Software
# URL: http://aptonic.com
# Version: 1.0
# RunsSandboxed: Yes
# MinDropzoneVersion: 3.0
$SUBJECT = "The file you requested"
$BODY = "Dear Mel Torme - Here's the file you requested."
$TO_NAME = "Mel Torme"
$TO_ADDRESS = "meltorme@emailaddress.com"
$FROM_ADDRESS = "Mel T Torme <meltorme@someotheremailaddress.com>"
def dragged
$dz.determinate(false)
if $items.length < 10 and not File.directory?($items[0])
# Just add this file as an attachment
escaped_email_file = $items[0].gsub(/["`$\\]/){ |s| '\\' + s }
email_file = "\"#{escaped_email_file}\""
$dz.begin("Creating message with attachment")
delete_zip = false
else
# Zip up files first
email_file = ZipFiles.zip($items, "files.zip")
delete_zip = true
end
`osascript <<END
set theSubject to "#{$SUBJECT}"
set theBody to "#{$BODY}"
set theAddress to "#{$TO_ADDRESS}"
set theAccount to "#{$FROM_ADDRESS}"
tell application "Mail"
set newMessage to make new outgoing message with properties {sender:theAccount, subject:theSubject, content:theBody & return & return}
tell newMessage
make new to recipient at end of to recipients with properties {address:theAddress}
set sender to {address:theAccount}
tell content
make new attachment with properties {file name:"" & #{email_file} & ""} at after the last paragraph
end tell
send
end tell
send newMessage
end tell
tell application "System Events"
set visible of process "Mail" to false
end tell
END`
ZipFiles.delete_zip(email_file) if delete_zip
$dz.finish("Message Created")
$dz.url(false)
end
def clicked
system("open /Applications/Mail.app >& /dev/null")
end
According to Dropzone's debug console, it fails with an error reading
475:481:
execution error: Mail got an error Can’t make {address:"Mel T Torme <meltorme@someotheremailaddress.com>"} into type rich text.
(-1700)
I'm not sure if that's telling me to escape that $FROM_ADDRESS instantiation text or if there's some other error.
Is there anybody out there that knows how to decipher and/or fix this type of error?
Thank you in advance for your time!