Script to copy Mail settings to local machine

Hi,

I have two macs, one a G4 connected to the internet and the other an iBook. I use Mail to recieve emails on the G4. I have written a script to copy the Mail identity from the G4 to the iBook via AirPort to use when I’m away from home.

I wanted the G4 to download the same emails again later, so I would have one complete list of emails received.

I wouldn’t mind comments or ideas about how to make this script better. I’m also looking for a way of changing the Mail prefs. for deleting emails from a remote server.


tell application "Finder"
	
	-- set variables
	set r_home to "REMOTE_NAME" -- short name for remote user
	set ip_addr to "REMOTE_IP_ADDRESS" -- ip address of remote machine
	set p_word to "REMOTE_USER_PASSWORD" -- password of remote user
	set home_path to ((home) as text)
	
	-- mount remote SharePoint - on error quit
	try
		mount volume "afp://" & r_home & ":" & p_word & "@" & ip_addr & "/" & r_home
	on error
		display dialog "Mailbox Copy terminated!" & return & return & ¬
			"Cannot mount remote sharepoint - Check connection" buttons {"OK"} default button 1
		return
	end try
	
	-- make new folder "Mail backup" on desktop to store old mailboxes & prefs.
	try
		make new folder at (home_path & ":Desktop" as alias) with properties {name:"Mail backup"}
	on error
		display dialog "Cannot create 'Mail backup' folder." & return & ¬
			"Folder already exists on Desktop" & return & return & ¬
			"Do you want to delete this folder?" buttons {"Stop", "Delete folder"} default button 1
		if the button returned of the result is "Delete Folder" then
			delete folder (home_path & ":Desktop:Mail backup" as alias)
			make new folder at (home_path & ":Desktop" as alias) with properties {name:"Mail backup"}
		else
			display dialog "Mailbox Copy terminated!" buttons {"OK"} default button 1
			return
		end if
	end try
	
	-- move Mail folder from Home/Library and Maiil prefs. from Home/Library/Preferences to Mail backup on Desktop
	move (home_path & ":Library:Mail" as alias) to (home_path & ":Desktop:Mail backup" as alias)
	move (home_path & "Library:Preferences:com.apple.mail.plist" as alias) to (home_path & ":Desktop:Mail backup" as alias)
	
	-- copy Mail folder and prefs. from remote Home/Library
	duplicate (r_home & ":Library:Mail" as alias) to (home_path & "Library" as alias)
	duplicate (r_home & ":Library:Preferences:com.apple.mail.plist" as alias) to (home_path & "Library:Preferences" as alias)
	
	-- change Mail prefs Warning
	display dialog "Mailbox Copy complete!" & return & return & "Set preferences for POP accounts in Mail to" & return & ¬
		"not remove messages from server." buttons {"OK"} default button 1
	
	-- Eject remote SharePoint
	eject (r_home as alias)
end tell

-- open Mail app.
tell application "Mail"
	activate
end tell

Thanks

John Maisey