Previous  |  Main  |  Next
AppleScript Logo

Check Mail Accounts

Script for: Mailsmith 1.x, 2.x (OS 9 & OS X)
Copyright: Matthias Steffens, use at your own risk!
Description: This script pops up a list dialog with all currently available mail accounts
(location support is honoured). All selected mail accounts will be checked.
Necessary: StandardAdditions.hqx from MacOS 8.5.x or greater  (command: "choose from list")
Download: Check_Mail_Accounts.hqx
The Script:
property SelectedAccountNames : {}

--  Set the variable 'ShowConnectionStatus' to false if you don't like
-- the script opening the 'connection status' window:
set ShowConnectionStatus to true

tell application "Mailsmith 1.1"
	set MailAccounts to every mail account -- get all mail accounts
	-- get names of all accounts we're allowed to check mail from:
	set MailAccountNames to {}
	repeat with Account in MailAccounts
		if (can check of Account) then
			copy name of Account to end of MailAccountNames
		end if
	end repeat
end tell

-- pop up a list with all currently available mail accounts to choose from:
-- (uses "Standard Additions" osax)
set dialogResult to choose from list MailAccountNames with prompt ¬
	"Check mail from account(s):" OK button name "Check Mail" cancel button name ¬
	"Cancel" default items SelectedAccountNames with multiple selections allowed without empty selection allowed

if dialogResult is not false then -- if false: user pressed "Cancel"
	set SelectedAccountNames to dialogResult
	set SelectedAccounts to {}
	-- get proper references for the selected accounts:
	repeat with Account in MailAccounts
		set AccountName to name of Account
		if (AccountName is in SelectedAccountNames) then
			copy Account to end of SelectedAccounts
		end if
	end repeat
	-- finally fetch mail for all selected accounts:
	tell application "Mailsmith 1.1"
		if ShowConnectionStatus then open connection status -- open the 'connection status' window
		check mail using SelectedAccounts -- check mail from selected accounts
	end tell
end if


Contact: Matthias Steffens  |  Previous  |  Main  |  Next  |  Last Updated: 16-Jun-00