<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Dropzone Forums — Assistance Incorporating Applescript into Dropzone Script]]></title>
	<link rel="self" href="https://forums.aptonic.com/feed/atom/topic/175/" />
	<updated>2014-08-18T02:15:29Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.aptonic.com/topic/175/assistance-incorporating-applescript-into-dropzone-script/</id>
		<entry>
			<title type="html"><![CDATA[Assistance Incorporating Applescript into Dropzone Script]]></title>
			<link rel="alternate" href="https://forums.aptonic.com/post/538/#p538" />
			<content type="html"><![CDATA[<p>Hi!&nbsp; 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.&nbsp; I wrote an applescript that works, but I can&#039;t seem to incorporate it into Dropzone.</p><p>Here&#039;s my stab at the Dropzone script:</p><div class="codebox"><pre><code># 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 = &quot;The file you requested&quot;
$BODY = &quot;Dear Mel Torme - Here&#039;s the file you requested.&quot;
$TO_NAME = &quot;Mel Torme&quot;
$TO_ADDRESS = &quot;meltorme@emailaddress.com&quot;
$FROM_ADDRESS = &quot;Mel T Torme &lt;meltorme@someotheremailaddress.com&gt;&quot;

def dragged
  $dz.determinate(false)

  if $items.length &lt; 10 and not File.directory?($items[0])
    # Just add this file as an attachment
    escaped_email_file =  $items[0].gsub(/[&quot;`$\\]/){ |s| &#039;\\&#039; + s }
    email_file = &quot;\&quot;#{escaped_email_file}\&quot;&quot;
    $dz.begin(&quot;Creating message with attachment&quot;)
    delete_zip = false
  else
    # Zip up files first
    email_file = ZipFiles.zip($items, &quot;files.zip&quot;)
    delete_zip = true
  end

`osascript &lt;&lt;END 
set theSubject to &quot;#{$SUBJECT}&quot;
set theBody to &quot;#{$BODY}&quot;
set theAddress to &quot;#{$TO_ADDRESS}&quot;
set theAccount to &quot;#{$FROM_ADDRESS}&quot;

tell application &quot;Mail&quot;
    set newMessage to make new outgoing message with properties {sender:theAccount, subject:theSubject, content:theBody &amp; return &amp; 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:&quot;&quot; &amp; #{email_file} &amp; &quot;&quot;} at after the last paragraph
        end tell
    send
    end tell
  send newMessage
end tell

tell application &quot;System Events&quot; 
  set visible of process &quot;Mail&quot; to false
end tell

END`

  ZipFiles.delete_zip(email_file) if delete_zip

  $dz.finish(&quot;Message Created&quot;)
  $dz.url(false)
end

def clicked
  system(&quot;open /Applications/Mail.app &gt;&amp; /dev/null&quot;)
end</code></pre></div><p>According to Dropzone&#039;s debug console, it fails with an error reading <br /></p><div class="codebox"><pre><code>475:481:
execution error: Mail got an error Can’t make {address:&quot;Mel T Torme &lt;meltorme@someotheremailaddress.com&gt;&quot;} into type rich text.
(-1700) </code></pre></div><p>I&#039;m not sure if that&#039;s telling me to escape that $FROM_ADDRESS instantiation text or if there&#039;s some other error.</p><p>Is there anybody out there that knows how to decipher and/or fix this type of error?</p><p>Thank you in advance for your time!</p>]]></content>
			<author>
				<name><![CDATA[MelTorme]]></name>
				<uri>https://forums.aptonic.com/user/410/</uri>
			</author>
			<updated>2014-08-18T02:15:29Z</updated>
			<id>https://forums.aptonic.com/post/538/#p538</id>
		</entry>
</feed>
