Purging propertys

I have the following script to send emails via Outlook Express/Entourage;

property default_address : “whoever@wherever.com
property mail_subject : “Client name”
global attachment_name

on open the_files
set attachment_name to name of (info for (the_files’s item 1))

tell me to activate

if mail_subject is "Client name" then
	display dialog "Enter the subject:" default answer mail_subject
	set the mail_subject to text returned of the result
end if

set the compression_setting to "No"
tell application "Microsoft Entourage"
	set MyMessage to make new draft window with properties ¬
		{recipient:default_address, subject:attachment_name & " - " & mail_subject, attachment:the_files}
	if class of window 1 is draft news window or class of window 1 is draft window then
		tell window 1
				set theNames to name of every attachment
			on error
				return -99 -- silent exit
			end try
			if (count theNames) > 1 then
				set messageText to ""
				repeat with aName in theNames
					set messageText to messageText & return & tab & aName
				end repeat
				set messageText to messageText & return & return
			else if (count theNames) = 1 then
				set messageText to return & theNames & return & return
			end if
			set selection to messageText
		end tell
	end if
	send MyMessage
end tell
tell application "Finder"
end tell

end open

What I want it to do is ask the client name each time you run the script, however, it holds the client name from the first time you entered it and doesn’t give an option to change it. How do I reset this variable each time I drag and drop a file?

Also, would it be possible to attach this script to a watched folder that cycles through the list of files and sends each one as an individual email - they will only ever get sent to the one email address which hopefully makes it easier!

Just add a line:

set default_address to text returned of (display dialog “Enter recipient’s name” default answer default_address )

This will display a dialog asking for a new address, using the last used address as the default answer.

To do this you need to change the ‘on open the_files’ handler to ‘on adding items to the_folder after receiving the_files’ and the corresponding end open, and you’re done. Since both work on a list of files you don’t need to make any other changes.

Once done, use the Script menu’s ‘Attach Script to Folder’ script to attach it to your folder.

It was actually the client name I wanted to put in the subject line but I changed the property names accordingly and it works perfectly
Thanks for your help!!


I’ve replaced the line ‘on open the_files’ with ‘on adding items to the_folder after receiving the_files’, there is already an end open statement at the end. When I try to compile it I get the following error;
‘Expected “given”, “into”, “without” or other paramter name but found plural class name’

What not simply using a global variable, and make a handler where you wol ask the user all the information?

Jean-baptiste LE STANG(who might be missing something there?)