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


Sending email using BrainForest and Mailsmith

Author Jan Erik Moström
Last modified 2001-03-26
What is this?

Note: I haven't tested it much

This is something my wife said she needed. She wanted some way of writing emails on her Palm and then send them from the Mac. There are a few other methods of doing this but they either involve extra software and/or expensive software ... so here is a way of doing it with the help of BrainForest.

To send an email you make an outline like this (normally you would write this on the Palm and then do a HotSync to get the file to the Mac. Start BrainForest and open the tree you wrote on the Palm):

bf

To create a message you create a top level item that is called "Mail". Inside that you create a number of sub items called "To", "Subject" and "Body". To each of these you add a note with the desired information, for example:

To
donald@disney.com
daisy@disney.com
Subject
Free dinner
Body
Here is some suitable text ... max 4000 chars in each note

You don't need to specify all three parts (if you don't one, that part will be left empty in the email message). So in the picture above there are two messages specified, the first with all three parts defined. The second one doesn't have a "To" item but instead two "Body" items, these two body items will be joined and put into the message part.

Well, now it's time for the script. Just leave the outline as the top window in BrainForest and select the export script from the scripts menu. The script will then scan the outline, find the "Mail" items and create one message for each.

Installation
Copy the script, paste it into a script editor (Script Editor, Scripter, Script Debugger or Smile), compile and save it into the script folder of BrainForest. You can then access the script from within BrainForest.


on run
  tell application "BrainForest"
    if the (count of documents) = 0 then
      display dialog "There is no document to translate"
    end if
    set theTree to the frontmost document
    set rootBranches to the tree items of theTree as list
    set noi to number of items of rootBranches
    set AppleScript's text item delimiters to {return}
    repeat with i from 1 to noi
      set curBranch to item i of rootBranches
      if title of curBranch = "Mail" then
        set msgParts to tree items of curBranch
        set mx to the number of items of msgParts
        set msgTo to ""
        set msgSubject to ""
        set msgBody to ""
        repeat with mp from 1 to mx
          set ci to item mp of msgParts
          if title of ci = "To" then
            set msgTo to note of ci
          else if title of ci = "Subject" then
            set msgSubject to note of ci
          else if title of ci = "Body" then
            if msgBody = "" then
              set msgBody to note of ci
            else
              set msgBody to msgBody & return & note of ci
            end if
          end if
        end repeat
        my makeMail(msgTo, msgSubject, msgBody)
      end if
    end repeat
  end tell
end run

on makeMail(msgTo, msgSubject, msgBody)
  tell application "Mailsmith 1.1"
    make new message window
    set subject of message window 1 to msgSubject
    set adrList to text items of msgTo
    set noi to the number of items of adrList
    repeat with i from 1 to noi
      if item i of adrList ≠ "" then
        make new to_recipient at end of message window 1 with properties {address:item i of adrList}
      end if
    end repeat
    set contents of message window 1 to msgBody
  end tell
end makeMail