Automatically giving messages subjects (in Entourage X)

I have the following script make the subject of my message the same as
the attachment’s name.

However, if an attachment’s name is file_for_meeting.pdf, I would like
the subject to read:

file for meeting
(without the underscores or the .pdf)

I think I know the syntax for replacing the underscore with spaces, and
how to delete “.pdf”, but i’m not sure where in the script they should

can I get a pointer?

The script as it is now:

tell application “Microsoft Entourage”
tell window 1
set theNames to name of every attachment
on error
return -99 – silent exit
end try
set the subject to theNames
end try
end tell
end tell

You must manipulate the text before you use it in the subject :wink:
This may do the job: