AppleScript to get current message from Entourage

J

Joel Nelson

Is there an AppleScript for Word 2004 to capture the message content(HTML)
or text (plain text) from the frontmost Entourage message window or the
currently displayed message and then paste the text/content in an open Word
document window?
 
P

Paul Berkowitz

Is there an AppleScript for Word 2004 to capture the message content(HTML)
or text (plain text) from the frontmost Entourage message window or the
currently displayed message and then paste the text/content in an open Word
document window?

Plain text is easy enough. HTML is not scriptable in Entourage.
(Theoretically, you could get the HTML coding from the HTML part of the
source of the message. There may be a way of using the same HTML code to
make a Word HTML file, then open it as a Word doc. I have a glimmer of an
idea as to how that might barely be possible - I'll try it later.) To get
the plain text (which will work also with HTML messages), it makes a
difference as to whether the Entourage "message" is one you received, or a
new message window you've composed but haven't sent yet. I'll assume it's
the former (received message).


tell application "Microsoft Entourage"
if class of front window is message window then
set theMsg to displayed message of front window
else
try -- if message is displayed in main window
set theMsg to item 1 of (get current messages)
on error
beep
return
end try
end if

set theContent to content of theMsg

end tell

tell application "Microsoft Word"
activate
-- for inserting in an open doc at the cursor, delete next two lines and
remove (* *) from following lines
set theDoc to make new document
set content of text object of theDoc to theContent

(*set theDoc to active document
set selection to theContent *)

end tell



I'd recommend saving this as a compiled script and saving it to here:

~/Library/Scripts/Applications/Microsoft Word/

or here:

~/Library/Scripts/Microsoft Word/


The first method will display the script as a menu item at the bottom of the
system's Script Menu only when you're in Word (handy if that's where you'll
be using it : - one click, no clutter in other apps). The second method will
put it as a submenu item in a "Microsoft Word" menu item in the Script Menu,
and will be available everywhere, no matter which app you're in.

To make the system script menu visible, go to
/Applications/AppleScript/Install Script Menu and double-click it. (Word
doesn't have its own script menu, unfortunately, but this isn't too bad. It
will run a lot faster than saving the script as an Application.) The script
menu looks like Entourage's but is on the right side of the menu bar, near
the other doodads. If you install it first, you can get direct to your user
Scripts folder above by selecting "Open Scripts Folder" at the top of the
menu.


--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/toc.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.
 
J

Joel Nelson

Thanks! That seems to work pretty well. Is there a way to have Word
capture basic headers (subject/date/from) to put at the beginning of the
quoted email?

Joel Nelson
 
P

Paul Berkowitz

tell application "Microsoft Entourage"
if class of front window is message window then
set theMsg to displayed message of front window
else
try -- if message is displayed in main window
set theMsg to item 1 of (get current messages)
on error
beep
return
end try
end if

set {theSubject, theSender, theDate, theContent} to theMsg's {subject,
sender, time sent, content}

set {dName, eAddress} to theSender's {display name, address}
if dName ‚ "" then
set theSender to (dName & " <" & eAddress & ">")
else
set theSender to eAddress
end if

end tell

set theContent to "From: " & theSender & return & "Date: " & theDate &
return & "Subject: " & theSubject & return & return & return & theContent


tell application "Microsoft Word"
activate
set theDoc to make new document
set content of text object of theDoc to theContent
end tell


It would be a lot more complicated to do the header labels in bold (in
Word).

--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/toc.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.



From: Joel Nelson <[email protected]>
Newsgroups: microsoft.public.mac.office.word
Date: Fri, 28 May 2004 09:05:31 -0500
Subject: Re: AppleScript to get current message from Entourage

Thanks! That seems to work pretty well. Is there a way to have Word
capture basic headers (subject/date/from) to put at the beginning of the
quoted email?

Joel Nelson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top