Apple-Mail, Note-ToDo from a Mail automatic generated

Hello,

I’m new to applescript, using a mac longer time. I using Snow Leopard and a german language.

Some worktroughs should being shorter, not more much cklicks and a drag&drop for making a note with an empty to do and a link to the selected email.

Szenario without applescript:
I’m at a account of mail and a mail is selected. Then I clicked to “New Note”(Neue Notiz) and open an empty note. Then I clicked to “New ToDo” (Neue Aufgabe), set the todo in this line.
Then I click on the selected email and move it to the new note. Before I set the mail to note you will be see a green dot with a “+”. The Email now is a file and if I cklick on this “file”, its opened the email to read and e.g. answer it or work with it.

Szenario with applescript:
I’m at a account of mail and a mail is selected. Then I clicked to “New Note” and in this new note are

  1. created an empty ToDo (Neue Aufgabe)
    and
  2. a link of the selected email is under the todo.
    –end

I’m searched and dont found an automaticsm for that work, if I click on “New Note”. But I found Quicksilver to make a hotkey of this application from applescript to work it.

In this application is:


tell application "Mail"
	activate
end tell

tell application "System Events"
  tell process "Mail"
    click the menu item "Neue Notiz" of the menu "Ablage" of menu bar 1
    click the menu item "Neue Aufgabe" of the menu "Ablage" of menu bar 1
  end tell
end tell

Thats the first step, it work without problems. Now the Problem:
I wish set a link to the selected message of the mailboxes and get it in the New Note (under the todo).

So I tried this:

tell application "Mail"
	activate
end tell

tell application "System Events"
	tell process "Mail"
		click the menu item "Neue Notiz" of the menu "Ablage" of menu bar 1
		click the menu item "Neue Aufgabe" of the menu "Ablage" of menu bar 1
		tell application "Mail"
			set auswahl to selected messages of message viewer 1 of application "Mail"
			move message  to "Neue Notiz"
		end tell
	end tell
end tell

But “move message to “Neue Notiz”” doesnt work, because “to:Neue Notiz” cant follow “move message”.

I have no idea, what I can do now.

Maybe its important to set the cursor outside of the todo? How I can do it, if its important?

it would be great to help me! :slight_smile:

Model: Mac Book Pro
AppleScript: 2.3
Browser: Firefox 12.0
Operating System: Mac OS X (10.6)

I’am on Lion now and it seems that you can’t create an todo in Mail any longer…

Nevertheless you still can create todo’s in iCal and this should be the same under Snow Leopard.

To do so and have an link back to the email you can try this:


-- get the message id and the subject from the first selected message
tell application "Mail"
	set selectedMessages to selection
	set {theMessageId, theSubject} to {message id, subject} of item 1 of selectedMessages
end tell

-- build an url string
set theUrl to "message:%3C" & theMessageId & "%3E"

-- make a new todo
tell application "iCal"
	make new todo at the end of todos of calendar "Büro" with properties {summary:theSubject, url:theUrl}
end tell

Of course you have to change the name of the calendar to your preferred calendar name.

Stefan

Hello Stefan,

much thanks for your reply. I was busy in the last time, so my answer today.
Unfortunately I’m using Snow Leopard and not Lion, also I know, that in Lion is in Mail not impossible to create “Notes” and “ToDos”. So I don’t changing to Lion and stay Snow Leopard, because I using very much Notes and ToDos in Mail. I need Notes in Mail, because in iCal I cant so very good work with Notes from iCal.

I know, Mountain Lion is coming soon and have Notes and ToDos too (but outside of Mail), I would see, how its working. Till to Mountain Lion, I still working with Snow Leopard and Mail with Notes and ToDos.

So now I ask again, what I can do for making an URL in Notes in Mail (not in iCal).
I have try your idea for iCal making for Mail, the first both tiles work too, but I haven’t idea for tell Mail to set a URL in the Note.


tell application "Mail"
	activate
	set selectedMessages to selection
	set {theMessageId, theSubject} to {message id, subject} of item 1 of selectedMessages
end tell

set theUrl to "message:%3C" & theMessageId & "%3E"

tell application "System Events"
	tell process "Mail"
		click the menu item "Neue Notiz" of the menu "Ablage" of menu bar 1
		click the menu item "Neue Aufgabe" of the menu "Ablage" of menu bar 1
		make new text with properties {summary:theSubject, URL:theUrl}
	end tell
end tell