I just set up “SMTP Location E” script and it works GREAT!! but after running the script the Location MGR. Control panel stay’s open? Is this correct?
Roger
On 11/8/00 8:18 PM, I wrote:
> On 11/8/00 8:06 PM, "j.d. o'grady" <[EMAIL PROTECTED]> wrote:
>
>> there has got to be a better way to switch SMTP servers for multiple
>> accounts on a daily basis, right? please send responses to me directly
>> ([EMAIL PROTECTED]) and to the list as you see fit.
>
>
> I have written a script SMTP Location E which does all this by itself. I
> haven't posted it yet because I have yet to write the ReadMe. I'll get it
> to you soon.
OK, SMTP Location E now posted as a compiled script with a ReadMe at
AppleScripts for Entourage & Outlook Express
at <http://homepage.mac.com/berkowit28/ >
SMTP Location E
SMTP Location E allows you to set up your Location Manager settings once, and from then on Entourage will reset all your SMTP settings to your current location, automatically at Startup. Even if you have advanced SMTP settings on certain accounts, such as SMTP authentication or SSL, the script will take care of everything.
Requirements: Microsoft Entourage. Jon’s Commands osax (scripting addition), available free at http://www.osaxen.com.
Since there seems to be some interest, here's the script. Most of it is in the setting-up. It allows optionally for every advanced SMTP setting in Entourage (SMTP Authentication, SSL, etc. etc.) Otherwise just put in the SMTP address and click “Next” for the next account, or “Done” when done.
INSTALLATION
Put SMTP Location E script into your Entourage Script Menu Items folder in the Microsoft Users Data folder in your Documents folder.
If you do not already have it, get Jon’s Commands Scripting Addition (osax), free at http://www.osaxen.com or at http://homepage.mac.com/berkowit28/. Put it in the Scripting Additions folder in your System Folder. Restart your computer.
SET-UP & OPERATION
Run the script once from the script menu to put in all your settings. The dialog boxes will guide you through it. The Advanced settings are optional for each account: click “Sending Options” in the dialog box that comes up. Otherwise, you just need to put in the SMTP address and click “Next” for the next account or “Done” when done.
You can reset all settings at any time by running the script while holding down the Command and Control keys down. To add a new Location setting at any time, run the script with Command and Shift buttons down. To change settings for any particular location run it with Command, Shift and Control buttons down and select the location in the list that comes up.
For normal use, just make a new Schedule to run the script At Startup. That’s it: everything will be taken care of.
---------------SMTP Location E ------------------------------
property theLocs : {}
property theRecs : {}
set keyspressed to {}
try
set keyspressed to (keys pressed) -- Jon's Commands
if keyspressed = {"Command", "Control"} then
set theLocs to {}
set theRecs to {}
end if
end try
if theLocs = {} then set keyspressed to {"Command", "Control"} -- as if, first time
if keyspressed contains {"Command"} then
tell application "Location Manager"
if keyspressed = {"Command", "Control"} then --starting from scratch
repeat with i from 1 to (count every location)
set end of theLocs to name of location i
end repeat
else if keyspressed = {"Command", "Shift"} then -- if adding a new one
repeat with i from 1 to (count every location)
set theName to name of location i
if {theName} is not in theLocs then
set end of theLocs to theName
end if
end repeat
end if
end tell
try
set num to (count theLocs)
if keyspressed = {"Command", "Control"} then -- first time or resert all, do all
set a to 1
set z to num
else if keyspressed = {"Command", "Shift"} then -- add a new one
set a to num
set z to num
else if keyspressed = {"Command", "Shift", "Control"} then -- change one setting
choose from list theLocs with prompt "Change which location's settings?"
if result = false then
error number -128
else
set theLoc to item 1 of result
repeat with k from 1 to num
set whichRec to item k of theRecs
if locat of whichRec = theLoc then
set a to k
set z to k
exit repeat
end if
end repeat
end if
end if
repeat with j from a to z --
if keyspressed � {"Command", "Shift", "Control"} then -- defined already there
set theLoc to item j of theLocs
end if
set theRec to {locat:theLoc, SMTP:"", Options:{}}
if j � z then
set LB to "Next"
else
set LB to "OK"
end if
set dispA to display dialog "Enter the SMTP server for your " & theLoc & " location." & return & return & "If any Advanced options such as SMTP Authentication are required, click the Sending Options button." default answer "" buttons {"Cancel", "Sending Options", LB} with icon 1
if button returned of dispA = "Cancel" then error number -128
set theSMTP to text returned of dispA
set SMTP of theRec to theSMTP
if button returned of dispA = "Sending Options" then
set theOptions to {SSL:false, overrid:false, prt:25, auth:false, sameSet:true, username:"", pass:""}
set dispB to display dialog "Does this SMTP service require secure connection (SSL)?" buttons {"Yes", "No"} default button "No" with icon 1
if button returned of dispB = "Yes" then set SSL of theOptions to true
set dispC to display dialog "Override default SMTP port?" default answer "25" buttons {"Yes", "No"} default button "No" with icon 1
if button returned of dispC = "Yes" then
set overrid of theOptions to true
try
set prt of theOptions to (text returned of dispC) as integer
on error
set problem to true
repeat until problem is false
set dispD to display dialog "You must enter a whole number for the port : " default answer "25" buttons {"Cancel All", "No Override", "OK"} default button "OK" with icon 2
if button returned of dispD = "Cancel All" then
error number -128
else if button returned of dispD = "No Override" then
set overrid of theOptions to false
set problem to false
else
try
set prt of theOptions to (text returned of dispD) as integer
set problem to false
end try
end if
end repeat
end try
end if
set dispE to display dialog "Does SMTP server require authentication (username, password)?" buttons {"No", "Same as Incoming Mail", "Log On Different"} with icon 1
if button returned of dispE = "Same as Incoming Mail" then
set auth of theOptions to true
else if button returned of dispE = "Log On Different" then
set auth of theOptions to true
set sameSet of theOptions to false
set dispF to display dialog "Enter your Account ID (username) for this SMTP account:" default answer "" with icon 1
set username of theOptions to text returned of dispF
set dispG to display dialog "Enter your Password for this SMTP account:" default answer "" with icon 1
set pass of theOptions to text returned of dispG
end if
set Options of theRec to theOptions
end if -- Sending Options
if keyspressed � {"Command", "Shift", "Control"} then
set end of theRecs to theRec
else
set item j of theRecs to theRec
end if
end repeat
on error errMsg number errNum -- usually Cancel
if errNum � -128 then
display dialog errMsg
else
if keyspressed � {"Command", "Control"} then
display dialog "No changes were made to your settings." with icon 1
error number -128
else
set theLocs to {}
set theRecs to {}
display dialog "All settings have been set to empty." & return & return & " You will need to run the script again to set it up." with icon 2
error number -128
end if
end if
end try
return
end if -- setting up
--------------------NORMAL RUN------------------------
tell application "Location Manager" to set currLoc to name of (get current location)
tell application "Microsoft Entourage"
set theRec to {}
set num to (count theRecs)
repeat with i from 1 to num
set aRec to item i of theRecs
if locat of aRec = currLoc then
set theRec to aRec
exit repeat
end if
end repeat
if theRec = {} then
beep 2
display dialog "You seem to have added a new location without setting up the SMTP Location script." & return & return & "To be able to set your accounts to this location, first run the script with Command and Shift buttons down." buttons {"OK"} default button "OK" with icon 2
return
end if
set allAccounts to (every POP account) & (every IMAP account)
repeat with theAccount in allAccounts
set SMTP server of theAccount to SMTP of theRec
if Options of theRec � {} then
tell theAccount
set SMTP requires SSL to theRec's SSL
if theRec's Options's overrid is true then set SMTP port to theRec's Options's prt
if theRec's Options's auth is true then
set SMTP requires authentication to true
if theRec's Options's sameSet is true then
set SMTP uses account settings to true
else
set SMTP uses account settings to false
set SMTP account ID to theRec's Options's username
set SMTP password to theRec's Options's pass
end if
else
set SMTP requires authentication to false
end if
end tell
end if
end repeat
end tell
------------------------------end script---------------------------------
