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


Changing account setups

Author Christian Smith
Last modified 1999-08-04
What is this?

Earlier today I was asked:

> Hey -- I've been digging deeply into Mailsmith and can't seem to find a
> way (if there is one) to juggle multiple SMTP servers (i.e. by using the
> Internet Control Panel and Location Mananger).

I gave this some thought and came up with a very nifty script. This script can be run from the Mailsmith Script menu, as a Mailsmith Startup Script, or you can save it as an application and attach it to a location as an auto-open item.

The script looks at the current location, compares it to a list of known locations and if it matches one of them it checks to see if Mailsmith is running. If Mailsmith is running it spins thru each account and sets the pop and smtp servers accordingly.

It should not be to hard for you to edit the script to accomodate more or fewer accounts as well as additional account settings (such as whether to and when to auto-check, etc).

This isn't quite as spiffy as having an actual Mailsmith module for the Location Manager but it gets you pretty darn close.


-- Edit this line to list the locations the script should know about.
set location_list to {"location one", "location two"}

tell application "Platsinställningar"
  set current_location to current location
  set location_name to name of current_location
  set known_location to false
  
  repeat with i in location_list
    if location_name = (i as text) then set known_location to true
  end repeat
  
  
  if known_location then
    my config_mailsmith(location_name)
  else
    
    -- If the current location is unknow we display a dialog.
    display dialog "Current location is unknown" buttons "Opps"
    
  end if
end tell

on config_mailsmith(location_name)
  tell application "Finder"
    
    -- This is cool. We check to see if Mailsmith is in the list of current apps. 
    -- If it is we continue. Otherwise we don't do anything.
    -- This lets the script be run as an auto-open item without it launchoing Mailsmith.
    
    if (exists process "Mailsmith 1.1" of application "Finder") then
      
      -- Here we setup the list of settigs for each account.
      
      if location_name is "location one" then set account_settings to ¬
        {{popserver:"some.pop.server", smtpserver:"some.smtp.server"}, ¬
          {popserver:"some.pop.server", smtpserver:"some.smtp.server"}}
      
      if location_name is "location two" then set account_settings to ¬
        {{popserver:"another.pop.server", smtpserver:"another.smtp.server"}, ¬
          {popserver:"another.pop.server", smtpserver:"another.smtp.server"}}
      
      -- Now we spin thru the acounts and set the items for each.
      repeat with i from 1 to 2
        tell application "Mailsmith 1.1"
          set pop server of mail account i to popserver of item i of account_settings
          set smtp server of mail account i to smtpserver of item i of account_settings
        end tell
      end repeat
    end if
  end tell
end config_mailsmith