reading word documents and setting the from field in OE

I’ve written what seems to be called a droplet (you drop a file on a script icon etc…) that works like this:

  1. a (text) file is dropped on it
  2. the finder reads the contents of the file to a variable
  3. outlook is opened
  4. a new draft window is opened with some predefined properties and the contents of the email is set to the variable created in part 2.

Now the problem with this is that while it works fine with plain text files it doesn’t work at all with word (.doc i suppose) files. Any suggestions?

I also would like to know how, or if, there is a way to set the from field in outlook express.

thanx.

this is the script i use now:

on open the_files
tell application “Finder” to set fs to the_files
set body to (read fs)
tell application “Outlook Express”
make new draft window with properties {to recipients:"a@b.com", subject:“Blah”, content:body}
end tell
end open

Well, I can’t test it right now, but you’d need to do something along the lines of the following:

on open the_files
repeat with i in the_files
set this_file to i's contents
tell application "Finder" 
if name extension of item this_file is "doc" then
tell app "Microsoft Word"
open {this_File}
tell document 1
set body to (get its text)
close it
end
else
set body to (read fs)
end 
tell application "Outlook Express" 
make new draft window with properties {to recipients:"a@b.com", subject:"Blah", content:body} 
end tell
end
end open

Since Word docs aren’t plain text, you want to ask Word to give you what it thinks the documents text is.

thanks for the help

the code seems to work fine except for this part


tell document 1 
      set body to (get its text) 
      close it 
end tell

it gets as far as opening word and then the mac crashes. It freezes up. Any idea why?

Turns out ‘body’ is a reserved word in Word. Try something like this:

tell document 1
set theBody to (get its text)
close it without saving
end tell