Getting subject line from attached file in Entourage

Hi
I have the following script that lets you drag and drop a file, creates an email with the attachment, lists the names of the attachments in the message body and sends it. It works fine, however, I want to set the subject of the file to the name of the attachment (there will never be more than one attachment). Does anyone have any idea how I can do thos?
thanks!!

property default_address : “whoever@whatever.com
property mail_subject : “what is the subject of your email”

on open the_files
repeat with eachFile in the_files
end repeat

tell me to activate

if mail_subject is "what is the subject of your email" 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 "Yes"
tell application "Microsoft Entourage"
	activate
	set MyMessage to make new draft window with properties ¬
		{recipient:default_address, subject:mail_subject, content:my_content, attachment:the_files, encoding:AppleDouble, compression type:stuffit compression}
	
	if class of window 1 is draft news window or class of window 1 is draft window then
		tell window 1
			try
				set theNames to name of every attachment
			on error
				return -99 -- silent exit
			end try
			if (count theNames) > 1 then
				set messageText to return & ""
				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"
	activate
end tell

end open :shock:

Simply add a new global:

global attachment_name

And store this value from your first open handler:

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

I’m addressing target of “info for” to the_files’s item 1, since the_files is a list of aliases {alias “HD:file”}
You can also delete the “repeat” statement, because you’re not processing items of “the_files” individually.
Then, put this value into the subject:

set MyMessage to make new draft window with properties ¬ 
{recipient:default_address, subject:attachment_name, content:my_content, attachment:the_files, encoding:AppleDouble, compression type:stuffit compression}

That worked perfectly!!

The variable my_content is not defined.

Where did you define this??

I suppose “my_content” is a dummy variable name containing some text. You can define it before the “make new draft window” statement at any place.

Yeah I figured that afterwords… I was wondering if he was inputting a default text or invoked a dialog box to enter it at some point but didn’t see where. For that matter, I can’t determine WHERE he adds the name of the attachment to part of the body message either. I’m kinda new at this and trying to learn from others. Also, his dialog about the subject line is no longer necessary if he’s using the name of the attachments.

I’d love to modify this so I could collect content from a filemaker database to use as the message and attach a pdf and then send… any ideas where to start with making that happen?

it’d be really easy just to extract data from FM to email (eiither via Scriptmaker or AppleScript into Entourage. Why does it have to be a PDF?

I am actually trying to accomplish the reverse. I would like to save the attachment of an email and rename the attachment with the subject of the email. Does anyone know how to do this. I am new to AppleScripting. I have tried to do this myself but I keep getting the following error:

Can’t get name of attachment.

Here is what I have so far

tell application “Microsoft Entourage”
get incoming message
if name of attachment is “Document.pdf” then
set NewName to {subject of incoming message}
save attachment as NewName in desktop
end if
end tell

2 Trash Man and other

how would u transform this script if u dont need to attach files? If u only need names of files? I talking about because I need get some info via email about realy big files…