Mailsmith
Other Programs
Scripts
Mailsmith.scpt
Archive to sub-mailbox
Check Spelling
Find reply
Change font size
Submit Script to JEM
Fix common spelling errors
Setting SMTP server
URL from Safari
Address from AB
linkMunge
Export to Address Book
Saving attachments
Digest Script
File with same
POP window position
Position of new windows
iCal and Mailsmith
Edit From Line
Modified Thread Script
Reply to Selection
Temporary Text Window
Compact gain
Tracking backups
Edit subject
Googler
Auto-rewrap
MMA
SMTP server
Open, fetch, and close
URL Manager
BrainForest
Thread by Author
Thread by subject
Export Email
Get Selection
Read Addresses
Export Email
Organize Email
Account setup
Mailsmith 2 BBEdit
BBEdit 2 Mailsmith
Search II
Check One
Delete Enclosure
Open, fetch, close
Set Answered
Set Redirected
Empty Trash
List found
Print Several
Del. old. msg.
Delete Enclosures
Accounts
Address Book
Editing
Filters
General
Import/Export
Links
Mailboxes
Memory
Scripting
Speed
send/receive
Tips/Tricks


Reply to Selection From Digest Message

Author Brennan Young
Last modified 2002-11-22
What is this?
Mailing list digests are great, but doing all that 'on [date] [original poster] wrote' always ends up looking like it was written by the mailing list. With this script, you select the 'message' from the digest you want to reply to and it does the right thing.

tell application "Mailsmith"
  
  set messageExists to ((message of window 1) exists)
  if not messageExists then
    display dialog "No message" buttons {"OK"} default button 1
    return
  end if
  
  set m to (message of window 1)
  
  tell m
    set sndr to (reply_to as string)
  end tell
  
  
  set sel to (get (selection of window 1))
  if (class of sel) is not string then
    display dialog "Please select part of the message text" buttons {"OK"} default button 1
    return
  end if
  
  set linez to (paragraphs of sel)
  set msgDate to ""
  set msgSendr to ""
  set msgSubj to ""
  set requiredReplyItems to 3
  set msgBody to ""
  set gatheringBody to false
  set lCount to (count (paragraphs of sel))
  
  repeat with li from 1 to lCount
    
    set l to (paragraph li of sel) as string
    
    if gatheringBody then
      set msgBody to msgBody & "> " & l & return
    else
      if l starts with "From:" then
        set msgSendr to l
        set o to (offset of ":" in msgSendr)
        set msgSendr to (characters (o + 2) thru end of msgSendr) as string
        set requiredReplyItems to requiredReplyItems - 1
        
      end if
      if l starts with "Date:" then
        set msgDate to l
        set o to (offset of ":" in msgDate)
        set msgDate to (characters (o + 2) thru end of msgDate) as string
        set requiredReplyItems to requiredReplyItems - 1
        log msgDate
      end if
      
      if l starts with "Subject:" then
        set msgSubj to l
        set o to (offset of ": " in msgSubj)
        set msgSubj to (characters (o + 2) thru end of msgSubj) as string
        set requiredReplyItems to requiredReplyItems - 1
      end if
      
      if requiredReplyItems = 0 then
        if l is "" then
          set msgBody to "On " & msgDate & ", " & msgSendr & " wrote:" & return & return
          set gatheringBody to true
        end if
        
      end if
    end if
  end repeat
  if (word 1 of msgSubj) does not contain "Re" then
    set msgSubj to ("Re:" & msgSubj)
  end if
  
  tell (make new message window with properties {contents:msgBody})
    make new to_recipient with properties {address string:sndr}
    set subject to msgSubj
  end tell
  
end tell