Stuff and Mail Attachment

Hi! I am trying to write a droplet that will take a file, stuff it with DropStuff and then attach it to a Mail message and send it to a given address (the same address every time) using Mail. So far I have managed the following but I seem to have problems getting the script to actually attach the file and difficulty accessing the stuffed file or its name. I am confused! Any help gratefully received. Thanks. Code follows:

on open fileList
set fileName to name of (info for fileList)
tell application “DropStuff”
stuff fileList with format StuffItX
quit “DropStuff”
end tell
set stuffedfile to fileName & “.sitx”
tell application “Mail”
set this_message to make new outgoing message with properties {subject:“From Ian”, visible:true, content:return & return}
tell this_message
make new to recipient with properties {address:“myemail address”}
display dialog fileName
tell content
make new attachment with properties {file name:stuffedfile} at after the last paragraph
end tell
end tell
send this_message
end tell
end open

Hi,

Here’s an example using Jaguar Mail:

set the_sender to “me@somewhere.com
set the_subject to “Testing”
set r to return
set the_content to “Hi,” & r & r & “Here’s the stuffed file.” & r
set recipient_name to “Joe”
set recipient_address to “joe@somewhereelse.com
set original_file to (choose file)
set file_name to (name of (info for original_file))
set destination_folder to (choose folder)
tell application “DropStuff”
stuff original_file into destination_folder with binhexing
end tell
tell application “Finder”
set stuffed_file to (first file of destination_folder whose name contains file_name) as alias
end tell
tell application “Mail”
activate
set new_om to (make new outgoing message with properties ¬
{sender:the_sender, subject:the_subject, content:the_content, visible:true})
tell new_om
make new to recipient at end of to recipients with properties ¬
{name:recipient_name, address:recipient_address}
tell content
make new attachment at after last paragraph with properties ¬
{file name:stuffed_file}
end tell
end tell
end tell

Propbably needs error checking somewhere.

gl,

Thanks so much for the help. UNfortunately this script fails on the line:

set stuffed_file to (first file of destination_folder whose name contains file_name) as alias

Apparently ‘as alias’ seems to cause problems (which is, I think, to what I found when I tried scripting this).

Any ideas?

Thank you

James

Hi,

If you get an error on the ‘as alias’ coercion, then it means that the file is not there. It could be that the file is still being stuffed. You might want to try it on a very small file. I’ll look at it later, but this is the only thing I can think of right now.

gl,