<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Dropzone Forums — Assistance Incorporating Applescript into Dropzone Script]]></title>
		<link>https://forums.aptonic.com/topic/175/assistance-incorporating-applescript-into-dropzone-script/</link>
		<atom:link href="https://forums.aptonic.com/feed/rss/topic/175/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Assistance Incorporating Applescript into Dropzone Script.]]></description>
		<lastBuildDate>Mon, 18 Aug 2014 02:15:29 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Assistance Incorporating Applescript into Dropzone Script]]></title>
			<link>https://forums.aptonic.com/post/538/#p538</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (MelTorme)]]></author>
			<pubDate>Mon, 18 Aug 2014 02:15:29 +0000</pubDate>
			<guid>https://forums.aptonic.com/post/538/#p538</guid>
		</item>
	</channel>
</rss>
