<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Using Mail.app with multiple users — using AppleScript: Part 2</title>
	<atom:link href="http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/feed" rel="self" type="application/rss+xml" />
	<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2</link>
	<description>Hacks, scripts and ideas for the refined geek.</description>
	<pubDate>Tue, 06 Jan 2009 13:24:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Kishan Dattani</title>
		<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/comment-page-1#comment-671</link>
		<dc:creator>Kishan Dattani</dc:creator>
		<pubDate>Thu, 10 Jul 2008 15:26:51 +0000</pubDate>
		<guid isPermaLink="false">http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2#comment-671</guid>
		<description>hey guys....really new to apple, only got it last week
i started using mail and realised that i had the same problem, as in anyone could click on mail and see all my mail, i have used all your ideas so thank you to everyone but have made some adjustments.....not really sure how relevent or usefull they are but it gave me a big smile when it worked.
i have added a couple lines that will quit mail when a new login is made and then re-opens it to the new user.

set theMailUsers to {"luke"}
choose from list theMailUsers with title "Choose the Mail account to use..."
set selectedMailUser to result as string
if selectedMailUser is "luke" then
	set thePassword to "skywalker"
	display dialog "Enter the password to acceess this account: " default answer ""
	set dialogInfo to result
	set theAttempt to text returned of dialogInfo
	if theAttempt is equal to thePassword then
		tell application "Mail"
			if application "Mail" is running then
				quit
				delay 1
			end if
			activate
			delay 0
			set enabled of account "luke" to true
		end tell
	else
		tell application "Mail" to set enabled of account "luke" to false
		display dialog "Incorrect password!" buttons {"OK"}
	end if
end if

its like coding in matlab....loads of fun
Peace Kishan</description>
		<content:encoded><![CDATA[<p>hey guys&#8230;.really new to apple, only got it last week<br />
i started using mail and realised that i had the same problem, as in anyone could click on mail and see all my mail, i have used all your ideas so thank you to everyone but have made some adjustments&#8230;..not really sure how relevent or usefull they are but it gave me a big smile when it worked.<br />
i have added a couple lines that will quit mail when a new login is made and then re-opens it to the new user.</p>
<p>set theMailUsers to {&#8221;luke&#8221;}<br />
choose from list theMailUsers with title &#8220;Choose the Mail account to use&#8230;&#8221;<br />
set selectedMailUser to result as string<br />
if selectedMailUser is &#8220;luke&#8221; then<br />
	set thePassword to &#8220;skywalker&#8221;<br />
	display dialog &#8220;Enter the password to acceess this account: &#8221; default answer &#8220;&#8221;<br />
	set dialogInfo to result<br />
	set theAttempt to text returned of dialogInfo<br />
	if theAttempt is equal to thePassword then<br />
		tell application &#8220;Mail&#8221;<br />
			if application &#8220;Mail&#8221; is running then<br />
				quit<br />
				delay 1<br />
			end if<br />
			activate<br />
			delay 0<br />
			set enabled of account &#8220;luke&#8221; to true<br />
		end tell<br />
	else<br />
		tell application &#8220;Mail&#8221; to set enabled of account &#8220;luke&#8221; to false<br />
		display dialog &#8220;Incorrect password!&#8221; buttons {&#8221;OK&#8221;}<br />
	end if<br />
end if</p>
<p>its like coding in matlab&#8230;.loads of fun<br />
Peace Kishan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manny</title>
		<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/comment-page-1#comment-667</link>
		<dc:creator>Manny</dc:creator>
		<pubDate>Wed, 09 Jul 2008 02:28:14 +0000</pubDate>
		<guid isPermaLink="false">http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2#comment-667</guid>
		<description>This is awesome!  Seriously, thank you!!  I followed your easy steps and had this up and running in a matter of minutes, with absolutely no issues!

Thanks so much!!</description>
		<content:encoded><![CDATA[<p>This is awesome!  Seriously, thank you!!  I followed your easy steps and had this up and running in a matter of minutes, with absolutely no issues!</p>
<p>Thanks so much!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Wise</title>
		<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/comment-page-1#comment-623</link>
		<dc:creator>Jonathan Wise</dc:creator>
		<pubDate>Fri, 06 Jun 2008 20:34:35 +0000</pubDate>
		<guid isPermaLink="false">http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2#comment-623</guid>
		<description>With iCal, I would wager that yes, you can. I can't look at the AppleScript iCal Dictionary from here (no Mac present) but I'm sure you could use script in a similar way to turn on and off Calendars.

With Address Book, the only solution I can think of is a shell script to swap out the underlying Address Book database -- which is very self-healing... so much so that this approach likely won't work. 

At any rate, I think if you want this much separation of data, a cost-benefit analysis would likely lead you to just create a different user login on your Mac.</description>
		<content:encoded><![CDATA[<p>With iCal, I would wager that yes, you can. I can&#8217;t look at the AppleScript iCal Dictionary from here (no Mac present) but I&#8217;m sure you could use script in a similar way to turn on and off Calendars.</p>
<p>With Address Book, the only solution I can think of is a shell script to swap out the underlying Address Book database &#8212; which is very self-healing&#8230; so much so that this approach likely won&#8217;t work. </p>
<p>At any rate, I think if you want this much separation of data, a cost-benefit analysis would likely lead you to just create a different user login on your Mac.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob</title>
		<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/comment-page-1#comment-614</link>
		<dc:creator>Jacob</dc:creator>
		<pubDate>Sat, 31 May 2008 20:42:32 +0000</pubDate>
		<guid isPermaLink="false">http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2#comment-614</guid>
		<description>Hi... This is exactly what I needed. Is it also possible to do the same with iCal and the address book?</description>
		<content:encoded><![CDATA[<p>Hi&#8230; This is exactly what I needed. Is it also possible to do the same with iCal and the address book?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Wise</title>
		<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/comment-page-1#comment-318</link>
		<dc:creator>Jon Wise</dc:creator>
		<pubDate>Sun, 09 Mar 2008 19:55:59 +0000</pubDate>
		<guid isPermaLink="false">http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2#comment-318</guid>
		<description>Ok Michael, I finally looked this up. Here's what you need to do:

In place of your statement:&lt;code&gt;
display dialog "Choose the Mail account to use" buttons {"Jon", "Nicole"} default button 1 with icon note
&lt;/code&gt;

Put this code to create a list box instead of a dialog box:&lt;code&gt;
set theMailUsers to {"Jon", "Nicole", "Luke", "Leia", "Yoda", "Darth Vader"}
choose from list theMailUsers with title "Choose the Mail account to use..."
set selectedMailUser to result as string
&lt;/code&gt;

Then, in place of each "if" statement, you'll need a slightly different condition checker:&lt;code&gt;
if selectedMailUser is "Jon" then
...
else if selectedMailUser is "Nicole" then
...
etc
...
end if
&lt;/code&gt;

That will give you a list box at start-up to chose from instead of buttons. I'm not sure what the maximum number of list items is, but it should be enough for even the largest of families! Hope this helps!</description>
		<content:encoded><![CDATA[<p>Ok Michael, I finally looked this up. Here&#8217;s what you need to do:</p>
<p>In place of your statement:<code><br />
display dialog "Choose the Mail account to use" buttons {"Jon", "Nicole"} default button 1 with icon note<br />
</code></p>
<p>Put this code to create a list box instead of a dialog box:<code><br />
set theMailUsers to {"Jon", "Nicole", "Luke", "Leia", "Yoda", "Darth Vader"}<br />
choose from list theMailUsers with title "Choose the Mail account to use..."<br />
set selectedMailUser to result as string<br />
</code></p>
<p>Then, in place of each &#8220;if&#8221; statement, you&#8217;ll need a slightly different condition checker:<code><br />
if selectedMailUser is "Jon" then<br />
...<br />
else if selectedMailUser is "Nicole" then<br />
...<br />
etc<br />
...<br />
end if<br />
</code></p>
<p>That will give you a list box at start-up to chose from instead of buttons. I&#8217;m not sure what the maximum number of list items is, but it should be enough for even the largest of families! Hope this helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Pacheco</title>
		<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/comment-page-1#comment-294</link>
		<dc:creator>Michael Pacheco</dc:creator>
		<pubDate>Wed, 05 Mar 2008 21:19:26 +0000</pubDate>
		<guid isPermaLink="false">http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2#comment-294</guid>
		<description>Hi Jon

Thanks for the reply. I've been trying the list box but have had no luck. I've never done any kind of programming be fore so not surprising I can't get it to work. 
What I have done in the mean time is split it into 2 applications one with 3 and one with 2 buttons.

Thanks for all the help this is great stuff.
This is why I love the internet!!</description>
		<content:encoded><![CDATA[<p>Hi Jon</p>
<p>Thanks for the reply. I&#8217;ve been trying the list box but have had no luck. I&#8217;ve never done any kind of programming be fore so not surprising I can&#8217;t get it to work.<br />
What I have done in the mean time is split it into 2 applications one with 3 and one with 2 buttons.</p>
<p>Thanks for all the help this is great stuff.<br />
This is why I love the internet!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Wise</title>
		<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/comment-page-1#comment-290</link>
		<dc:creator>Jonathan Wise</dc:creator>
		<pubDate>Wed, 05 Mar 2008 17:58:13 +0000</pubDate>
		<guid isPermaLink="false">http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2#comment-290</guid>
		<description>I didn't realise there was a 3 button limit. The only way I could think of would be to nest button sets... cludgy but it would work.
For example first level buttons like: A-J, K-S, T-Z and then once you've narrowed it down, you'd have less buttons to show on the second round...

Or! D’uh, I should have thought of this. What about a list box? That should be pretty easy to do, although i don’t know how off the top of my head. I’ll try to look into it tonite — I know I have some sample code somewhere that does a list box…</description>
		<content:encoded><![CDATA[<p>I didn&#8217;t realise there was a 3 button limit. The only way I could think of would be to nest button sets&#8230; cludgy but it would work.<br />
For example first level buttons like: A-J, K-S, T-Z and then once you&#8217;ve narrowed it down, you&#8217;d have less buttons to show on the second round&#8230;</p>
<p>Or! D’uh, I should have thought of this. What about a list box? That should be pretty easy to do, although i don’t know how off the top of my head. I’ll try to look into it tonite — I know I have some sample code somewhere that does a list box…</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Pacheco</title>
		<link>http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2/comment-page-1#comment-283</link>
		<dc:creator>Michael Pacheco</dc:creator>
		<pubDate>Tue, 04 Mar 2008 11:50:19 +0000</pubDate>
		<guid isPermaLink="false">http://software.jonandnic.com/hack/using-mailapp-with-multiple-users-%e2%80%94-using-applescript-part-2#comment-283</guid>
		<description>"You can add as many options as you want, just by comma seperating them, so instead of {”Jon”, “Nicole”} you could have {”Jon”, “Nicole”, “Luke”, “Leia”, “Yoda”}"

Every time I try it Applescript gives me the error message "Maximum of 3 buttons allowed." 

Is this a version problem? I'm using applescript editor V. 2.1.1. Is there a later version that allows more than 3 buttons?</description>
		<content:encoded><![CDATA[<p>&#8220;You can add as many options as you want, just by comma seperating them, so instead of {”Jon”, “Nicole”} you could have {”Jon”, “Nicole”, “Luke”, “Leia”, “Yoda”}&#8221;</p>
<p>Every time I try it Applescript gives me the error message &#8220;Maximum of 3 buttons allowed.&#8221; </p>
<p>Is this a version problem? I&#8217;m using applescript editor V. 2.1.1. Is there a later version that allows more than 3 buttons?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
