Oh-oh, another victim to scripting Mail (how do I restart Mail with AS?)...
Oh-oh, another victim to scripting Mail (how do I restart Mail with AS?)...
- Subject: Oh-oh, another victim to scripting Mail (how do I restart Mail with AS?)...
- From: Dave Stewart <email@hidden>
- Date: Fri, 20 Jun 2003 15:55:12 -0700
Hey folks!
For some reason, trying to script a very simple procedure in Mail has
reminded me of an old Chinese proverb -
"Confusion says what?"
Seriously, all I want to do is create a simple little script to restart
the Mail.app every day (why? Sometimes we do something to the mail
server here at work and Mail becomes very unhappy until it's restarted.
It just seemed like a nice little Friday project to script this so
people don't have to think about it). Unfortunately, likely due to my
total lack of experience with AS, I'm finding the simplest part
exceedingly difficult.
I'll deal with the neat things I want to add later (like checking if
Mail is running first, since telling Mail anything seems to fire it up
if it's not running; and of course the timing issue to make this happen
daily, and of course the stay open applet so it knows to do this daily
... at least I think that I assume that I want a stay open applet.
Don't ask too many questions, I'm not even sure what a stay-open applet
is, nor how to write one. But I digress, first things first ....)
I've started with these meager beginnings:
tell application "Mail"
quit
end tell
delay 10
tell application "Mail"
activate
check for new mail
end tell
What's throwing me isn't the fact this doesn't work (although that fact
probably should), but the fact that each half by itself does! If I try:
tell application "Mail"
quit
end tell
then Mail does in fact quit. Good! Now, if I try this:
tell application "Mail"
activate
check for new mail
end tell
then Mail does in fact start and check for mail. Super! Let's put it
together ...
tell application "Mail"
quit
(*This was my first thought ...*)
activate (*this is always the line where the error occurs*)
--check for new mail (*tried with and without this, doesn't matter*)
end tell
->Mail got an error: Connection is invalid
What? OK, try this ...
tell application "Mail"
quit
end tell
delay 10 --maybe it's just a timing issue?
tell application "Mail"
activate
end tell
->Mail got an error: Connection is invalid
So far today, I've tried a number of variations on this theme, but I
just can't make it go. The worst part is I know I've seen this in the
digests before, but I just can't find it (either in my archives,
Apple's archives, nor Google). So, what super important thingie am I
simply not getting here? Please don't make me write 3 scripts for this
(one to kill Mail, one to start Mail, and one to run them both), this
just shouldn't be complicated enough for that!
Assumptions:
- Mail seems to be working fine (I used it to send this message!)
- First project using Smile (you finally got through to me Emmanuel!),
but it seems to be working fine too.
Particulars:
OSX 10.2.6, 256M RAM, 450MHz G3
Mail 1.2.5
Smile 2.5.2 with Satimage osax (haven't tried SE 1.9 yet, thought I'd
figure out Smile instead. Besides, I need to Smile today!)
AS1.9.1
Dave Stewart
Aqua-flo Supply (Goleta)
email@hidden
The human mind ordinarily operates at only ten percent of its
capacity -- the rest is overhead for the operating system.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.