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


Submit Script to JEM

Author Paul Richardson
Last modified 2003-03-16
What is this?
A script to submit the contents of the frontmost Script Debugger window to Jan Erik Moström for the Mailsmith Script Archive. Designed to be run from Script Debugger.

property jem : "xxxx@xxxxx.xxx"
property subj : "Mailsmith Script Submission"
property glue : return & return
property sending_account : ""
property sender : ""
property scriptAuthor : "AUTHOR:" & return

-- initialise sending_account, sender, scriptAuthor on first run
if sending_account is "" then
  tell application "Mailsmith 1.5"
    set default_account to name of default account
    set accounts to name of every mail account whose can send is true
    tell me to set chosen_account to choose from list accounts with prompt "Send from:" default items default_account
    if chosen_account is in {"", false} then return -- user cancelled
    set sending_account to mail account (chosen_account as string)
    set scriptAuthor to scriptAuthor & sending_account's user name
    set sender to sending_account's name
  end tell
end if

-- get the script from Script Debugger
tell application "Script Debugger"
  if class of window 1 is script window then
    if modified of script document 1 is true then
      -- ask to save an unsaved document
      set ddButton to display dialog "This script has been modified since the last save." buttons {"Cancel", "Save and Continue"} default button 2 with icon 2
    end if
    set scriptTitle to "TITLE:" & return & name of script window 1
    set sdDescription to description of script document 1
    if sdDescription is "" then
      -- a script description is required
      display dialog "Please provide a description." buttons {"OK"} default button 1 with icon 0
      return
    else if "Mailsmith" is not in sdDescription then
      -- the script does not contain "Mailsmith" - is that correct?
      display dialog "The script does not appear to be a Mailsmith script." buttons {"Cancel", "Continue"} default button 1 with icon 2
    end if
    set scriptDescription to "DESCRIPTION:" & return & sdDescription
    set scriptCode to "SCRIPT:" & return & contents of script document 1
    -- document the submission
    set description of script document 1 to sdDescription & return & "Submitted to Jan Erik Moström on " & (current date)
    save script document 1
  else
    display dialog "The front window is not a script window." buttons {"OK"} default button 1 with icon 0
    return
  end if
end tell

-- create and queue/send the email
tell application "Mailsmith 1.5"
  set mailBody to scriptTitle & glue & scriptAuthor & glue & scriptDescription & glue & scriptCode
  set msg to make new message window with properties {sending account:sender, contents:mailBody, subject:subj, use signature:false}
  tell msg to make new to_recipient at end with properties {address string:jem}
  queue msg
  -- send msg
end tell