Stupid Mail.app Question

I’ve just switched from Eudora to Mail. If Mail is running with no windows showing and I want a script to open its window, what do I tell it?

Hi Adam,

something like this


tell application "Mail"
	make new message viewer with properties {selected mailboxes:{inbox}}
end tell

Thank you Stefan – I would not have guessed that.

I have not been able to find a way to select a smart mailbox (which doesn’t seem to show up in the list of mailboxes). Possible?

No, a smart mailbox in Mail.app is just a (Spotlight) search result, it’s not accessible by AppleScript

Pity, but thanks.

A

I’m trying to replicate a few scripts I used to run in Eudora. How do you close a message viewer window from a script, e.g.

tell application "System Events" to tell process "Mail"
	if exists window 1 then -- works properly
		-- close the damned window! -- can't find a method
	else
		tell application "Mail" to make new message viewer with properties {selected mailboxes:{inbox}}
	end if
end tell

This is part of a script (run by a Quicksilver hotkey) that toggles the window (or viewer) after a growl message of number of unread and their boxes.

Doesn’t this work?


tell application "Mail"
	if exists message viewer 1 then close window 1
end tell

message viewer and window is a synonym for some cases

Gotcha.

This will toggle the window.

tell application "Mail"
	if exists message viewer 1 then
		close window 1
	else
		make new message viewer with properties {selected mailboxes:{inbox}}
	end if
end tell

Hi

Sorry to invoke this old thread.

I have a similar problem. I am using an IMAP account which contains various mailboxes. I would like to open the mail.app window with one particular mailbox selected. However the following script does not work and shows me the error “AppleEvent Handler failed”

“make new message viewer with properties {selected mailboxes:{“FAQ”}}”

[FAQ is the name of the mailbox].

Can somebody help me please

Thank you

Hi,

first of all, inbox is a reserved word, to specify custom mailboxes you must use at least the keyword mailbox.
The “path” of an IMAP mailbox depends on the name of the root mailbox.
Try something like


.
make new message viewer with properties {selected mailboxes:{mailbox "INBOX/Office" of account "myAccount.com"}}
.

Thank you very much Stefan…It works

“Stupid Mail.app question” seems good place for me.

Customising Signature use
I want to use a Signature in Mail.app only when I send an email to “xyz” and no signature for emails sent to others. Would it be possible to do so?

use a script “template”, which creates an outgoing message with the parameters (signature, sender account, receipt etc.) you want

i generally do not compose emails to “xyz”…i only reply to emails sent by “xyz”. Think of “xyz” as a google group from where a receive new posts and i reply them. So, i dont think a template would work.

you can also reply to a message using a script, something like this


tell application "Mail"
	set eachMessage to item 1 of (get selection)
	tell eachMessage to set {theSender, theAddress, theSubject} to {extract name from sender, extract address from sender, subject}
	set newMessage to make new outgoing message with properties {subject:"Re: " & theSubject, visible:true}
	tell newMessage
		make new to recipient at end of to recipients with properties {name:theSender, address:theAddress}
		set message signature to signature "mySignature"
	end tell
	activate
end tell

Many thanks StefanK. It works.

all that i had to add was:

set mySignature to signature "name of a signature defined by me"

However, what would be the best way of invoking this script.
Only way I know of is setting a keyboard shortcut for executing the script, is there any alternative?

A keyboard shortcut would be the best solution for me,
but you can run it also from the script menu

thanks

My first post here so forgive me if this has already been mentioned.
http://www.indev.ca/MailActOn.html

Install this and it lets you set up keyboard shortcuts to run scripts or perform other “rule” actions.

For example, I like to colour the subject line of incoming messages so I can see at a glance which ones need urgent attention tomorrow or whatever.

[ctrl][r] sets a message to red, for example.

Martin (age 57)

Model: G4 QS with Sonnet 1.8GHz CPU
Browser: Safari 525.18
Operating System: Mac OS X (10.4)