Hi all, 
I tried to run the applescript below with mixed results. The script is
supposed to let you replace some or all of the message text with whatever
text you already have on the clipboard. If you have some of the message
text highlighted, it can replace just that with the clipboard. It will
ask you what to do. It can be a VERY handy little script to clean up
messages, etc. 

I ran the script as is, except for one change, replacing "Claris Emailer"
with "PowerMail". It complied ok, so i put it in the powermail additions
folder with the other scripts.  

Assumptions:
* you have an open message  in the frontmost window
* you have some text already copied on your clipboard. 
* you may or may not have highlighted some text in the message to replace.


Results:
* Replacing the entire message text works!  :-) 
* replacing only the highlighted selection does not. :-(
* It does correctly ask which to do. 

So, it appears to me that the script is not able to locate the selected
part of the message, or has trouble replacing just the selection. Is this
script using applescript dictionary commands that don't exist in
PowerMail? Maybe the syntax is not right? 

As someone recently brought up, is it important to trap for html messages
before doing anything else? 

Best,
 Dave Nathanson
 Mac Medix


> Below I have pasted an old applescript for Claris Emailer. It is for
>replacing all or part of an incoming message with whatever text is
>currently already copied on the clipboard. I've used this script for
>years & it worked great. Nicely done. What would it take to update this
>script to work with PowerMail 5? Can I trade you for something I can do
>for you?
>
>Best,
> Dave Nathanson
> Mac Medix
>
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>-- Script to replace message of open Emailer message with clipboard contents
>
>-- Allen Watson, 5/25/99
>tell application "PowerMail"
>       activate
>       try
>               set theMsg to the displayed message of the front window
>       on error
>               display dialog "There must be an open message for this script 
> to work"
>               return
>       end try
>       try
>               set theCopy to (the clipboard) as text
>       on error
>               display dialog "Cannot access clipboard; may be empty."
>       end try
>       if length of theCopy = 0 then
>               display dialog "Clipboard empty; nothing to replace WITH"
>               return
>       end if
>       try
>               set snippet to text 1 thru 60 of (theCopy as text)
>       on error
>               set snippet to theCopy as text
>       end try
>       display dialog "Choose: Replace entire message contents with clipboard?
>or replace selection?
>1st 60 characters are: " & snippet buttons {"Contents", "Selection",
>"Cancel"} default button 1
>       set theChoice to button returned of result
>       if theChoice = "Cancel" then return
>       if theChoice = "Contents" then
>               set the content of theMsg to theCopy
>       else
>               set theWindow to the front window
>               set theSel to selection of theWindow
>               set howLong to length of theSel
>               if howLong = 0 then
>                       display dialog "Nothing selected."
>                       return
>               end if
>               set theWhole to content of theMsg
>               set whereTo to (offset of theSel in theWhole)
>               --Pick out parts before and after theSel; handle when first/last
>character selected
>               if whereTo <= 1 then
>                       set partA to ""
>               else
>                       set partA to text 1 thru (whereTo - 1) of theWhole
>               end if
>               if (whereTo + (length of theSel)) >= (length of theWhole) then
>                       set partB to ""
>               else
>                       set partB to text (whereTo + howLong) thru -1 of 
> theWhole
>               end if
>               set theNew to partA & theCopy & partB
>               set the content of theMsg to theNew as text
>       end if
>end tell
>
>
>
>




Reply via email to