Emailanhang per Email Regeln in einen Ordner auf der HDD automatisch verschieben..

Hi Guys, hi Pill,

Seit 10.8 geht der Script nicht mehr, da kommt dann immer die Meldung: "Keine Scripts installiert", ich habe dann die Auswahl "Im Finder öffnen", dann öffnet er aber nur den Finder, jedoch kann ich dann nichts auswählen...

Wäre cool, wenn mir einer dabei mal wieder helfen könntet.

Liebe Grüße
Olly
 
Du musst das Skript in den Ordner (~/Library/Application Scripts/com.apple.mail/) kopieren, der sich öffnet, wenn du auswählst "Im Finder öffnen". Dann die Einstellungen schließen und wieder öffnen und du solltest das Skript auswählen können.
 
Vielen Dank!! Hat sehr gut gefunzt! Aber das Script geht jetzt wieder nicht mehr... :confused:

using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
set theOutputFolder to "Macintosh HD:Users:eek:liverrueckert:Desktop:scan:"
tell application "Mail"
set theMessage to item 1 of theMessages
set theAttachments to every mail attachment of theMessage
repeat with a from 1 to length of theAttachments
set theAttachment to item a of theAttachments
try
set theAttachmentName to name of theAttachment
set theSavePath to theOutputFolder & theAttachmentName
save theAttachment in theSavePath
end try
end repeat
end tell
end perform mail action with messages
end using terms from
 
Der Pfad ist wahrscheinlich wieder falsch. Wenn du auf dem Desktop einen Ordner "scan" hast, dann sollte das funktionieren:

Code:
[FONT=Verdana][size=2][b]using terms from[/b] [color=#0000FF][i]application[/i][/color] "Mail"
	[b]on[/b] [color=#0000FF][b]perform mail action with messages[/b][/color] [color=#3F7F00]theMessages[/color] [color=#0000FF]for rule[/color] [color=#3F7F00]theRule[/color]
		[b]set[/b] [color=#3F7F00]theOutputFolder[/color] [b]to[/b] "HD:Users:oliverrueckert:Desktop:scan:"
		[b]tell[/b] [color=#0000FF][i]application[/i][/color] "Mail"
			[b]set[/b] [color=#3F7F00]theMessage[/color] [b]to[/b] [color=#0000FF][i]item[/i][/color] 1 [b]of[/b] [color=#3F7F00]theMessages[/color]
			[b]set[/b] [color=#3F7F00]theAttachments[/color] [b]to[/b] [b]every[/b] [color=#0000FF][i]mail attachment[/i][/color] [b]of[/b] [color=#3F7F00]theMessage[/color]
			[b]repeat[/b] [b]with[/b] [color=#3F7F00]a[/color] [b]from[/b] 1 [b]to[/b] [color=#6C04D4]length[/color] [b]of[/b] [color=#3F7F00]theAttachments[/color]
				[b]set[/b] [color=#3F7F00]theAttachment[/color] [b]to[/b] [color=#0000FF][i]item[/i][/color] [color=#3F7F00]a[/color] [b]of[/b] [color=#3F7F00]theAttachments[/color]
				[b]try[/b]
					[b]set[/b] [color=#3F7F00]theAttachmentName[/color] [b]to[/b] [color=#6C04D4]name[/color] [b]of[/b] [color=#3F7F00]theAttachment[/color]
					[b]set[/b] [color=#3F7F00]theSavePath[/color] [b]to[/b] [color=#3F7F00]theOutputFolder[/color] & [color=#3F7F00]theAttachmentName[/color]
					[color=#0000FF][b]save[/b][/color] [color=#3F7F00]theAttachment[/color] [color=#0000FF]in[/color] [color=#3F7F00]theSavePath[/color]
				[b]end[/b] [b]try[/b]
			[b]end[/b] [b]repeat[/b]
		[b]end[/b] [b]tell[/b]
	[b]end[/b] [color=#0000FF][b]perform mail action with messages[/b][/color]
[b]end[/b] [b]using terms from[/b][/size][/FONT]
 
Die Festplatte heißt jetzt "Macintosh HD"

So?

Code:
using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		set theOutputFolder to "Macintosh HD:Users:oliverrueckert:Desktop:scan:"
		tell application "Mail"
			set theMessage to item 1 of theMessages
			set theAttachments to every mail attachment of theMessage
			repeat with a from 1 to length of theAttachments
				set theAttachment to item a of theAttachments
				try
					set theAttachmentName to name of theAttachment
					set theSavePath to theOutputFolder & theAttachmentName
					save theAttachment in theSavePath
				end try
			end repeat
		end tell
	end perform mail action with messages
end using terms from
 
Hi,

ich kann deinen Fehler bei mir unter ML nachvollziehen, es scheint ein Bug zu sein. Die Fehlermeldung taucht in der Zeile

"save theAttachment in theSavePath"

auf und lautet "Mail got an error: AppleEvent handler failed". Im Netz gibt's dazu einige Themen, insbesondere im Zusammenhang mit dem Upgrade auf ein neues Betriebssystem und mit Mailerweiterungen. Ich konnte den Fehler durch keine der vorgeschlagenen Lösungen (Rechte reparieren, Erweiterungen deinstallieren) bei mir lösen, lediglich das Neuaufsetzen des Betriebsystems wollte ich mir ersparen.

Meiner Meinung liegt daher der Fehler bei Apple, der Befehl "save mail attachment" scheint bei den mail actions nicht mehr zu funktionieren. Man müsste also einen Umweg finden, mir fällt da spontan nur GUI-Scripting ein, was allerdings nicht wirklich schön wäre.

Ich schau mir das Problem nächste Woche nochmal an, bis dahin noch ein schönes (Rest-)Wochenende.
 
So, ich bin jetzt etwas klüger als zuvor. Es handelt sich hier nicht um einen Bug, sondern um ein Feature ;) Um genauer zu sein verhindert das Sandboxing der Apps unter Mountain Lion, dass Mail die Dateien irgendwo speichert. Glücklicherweise ist es Mail erlaubt, in den Downloads Ordner zu speichern, folgendes Skript sollte also funktionieren:

Code:
[FONT=Verdana][size=2][b]using terms from[/b] [color=#0000FF][i]application[/i][/color] "Mail"
	[b]on[/b] [color=#0000FF][b]perform mail action with messages[/b][/color] [color=#3F7F00]theMessages[/color]
		[b]set[/b] [color=#3F7F00]theOutputFolder[/color] [b]to[/b] (([color=#0016B0][b]path to[/b][/color] [color=#261151]home folder[/color]) [b]as[/b] [color=#0000FF][i]string[/i][/color]) & "Downloads:"
		[b]tell[/b] [color=#0000FF][i]application[/i][/color] "Mail"
			[b]repeat[/b] [b]with[/b] [color=#3F7F00]theMessage[/color] [b]in[/b] [color=#3F7F00]theMessages[/color]
				[b]repeat[/b] [b]with[/b] [color=#3F7F00]theAttachment[/color] [b]in[/b] [b]every[/b] [color=#0000FF][i]mail attachment[/i][/color] [b]of[/b] [color=#3F7F00]theMessage[/color]
					[b]try[/b]
						[b]set[/b] [color=#3F7F00]theAttachmentName[/color] [b]to[/b] [color=#6C04D4]name[/color] [b]of[/b] [color=#3F7F00]theAttachment[/color]
						[b]set[/b] [color=#3F7F00]theSavePath[/color] [b]to[/b] [color=#3F7F00]theOutputFolder[/color] & [color=#3F7F00]theAttachmentName[/color]
						[color=#0000FF][b]save[/b][/color] [color=#3F7F00]theAttachment[/color] [color=#0000FF]in[/color] [color=#3F7F00]theSavePath[/color]
					[b]on[/b] [b]error[/b] [color=#3F7F00]err[/color]
						[color=#0016B0][b]display dialog[/b][/color] [color=#3F7F00]err[/color]
					[b]end[/b] [b]try[/b]
				[b]end[/b] [b]repeat[/b]
			[b]end[/b] [b]repeat[/b]
		[b]end[/b] [b]tell[/b]
	[b]end[/b] [color=#0000FF][b]perform mail action with messages[/b][/color]
[b]end[/b] [b]using terms from[/b][/size][/FONT]

Es sollte natürlich auch möglich sein in einen beliebigen Ordner innerhalb des Downloads Ordners zu speichern. Davon könnte man dann auch einen Alias in einen anderen Ordner machen.
 
Zuletzt bearbeitet:
Alles klar, I got you!

Bei mir kam dann folgende Meldung....

Bildschirmfoto 2012-08-13 um 20.58.53.jpg

nachdem ich es wie Du beschrieben eingegeben habe,

Bildschirmfoto 2012-08-13 um 21.39.42.jpg

habe ich irgendwo etwas falsch gemacht oder iwelche Gänsefüßchen zu viel oder zu wenig?
 
Ist korrigiert. Irgendwie wird beim Ausführen/Speichern des Skript aus "as string" plötzlich "rule type string"
 
Oh man, ich will Dir nicht auf den Sack gehen, aber leider tut sich nichts.

Hab extra darauf geachtet, dass dass as String auch as string bleibt. Hab Download gelassen, hab scan: ergänzt, leider funzt es in keinem aller Fälle...

Bildschirmfoto 2012-08-13 um 23.00.04.jpg

Jetzt mal ohne Mist, ist das wirklich ok, dass ich Dich hiermit belästige? Sag einfach, wenn Du keinen Bock mehr hast, könnte ich echt verstehen... ^^

LG
Olly
 
Das ist schon ok, ich helf ja gerne, wenn ich kann. Warum es allerdings bei dir nicht funktioniert, kann ich dir nicht sagen.

Du kannst mal das probieren und schauen, ob der Speicherpfad stimmt:

Code:
[FONT=Verdana][size=2][b]using terms from[/b] [color=#0000FF][i]application[/i][/color] "Mail"
	[b]on[/b] [color=#0000FF][b]perform mail action with messages[/b][/color] [color=#3F7F00]theMessages[/color]
		[b]set[/b] [color=#3F7F00]theOutputFolder[/color] [b]to[/b] (([color=#0016B0][b]path to[/b][/color] [color=#261151]home folder[/color]) [b]as[/b] [color=#0000FF][i]string[/i][/color]) & "Downloads:"
		[color=#0016B0][b]display dialog[/b][/color] [color=#3F7F00]theOutputFolder[/color]
		[b]tell[/b] [color=#0000FF][i]application[/i][/color] "Mail"
			[b]repeat[/b] [b]with[/b] [color=#3F7F00]theMessage[/color] [b]in[/b] [color=#3F7F00]theMessages[/color]
				[b]repeat[/b] [b]with[/b] [color=#3F7F00]theAttachment[/color] [b]in[/b] [b]every[/b] [color=#0000FF][i]mail attachment[/i][/color] [b]of[/b] [color=#3F7F00]theMessage[/color]
					[b]try[/b]
						[b]set[/b] [color=#3F7F00]theAttachmentName[/color] [b]to[/b] [color=#6C04D4]name[/color] [b]of[/b] [color=#3F7F00]theAttachment[/color]
						[b]set[/b] [color=#3F7F00]theSavePath[/color] [b]to[/b] [color=#3F7F00]theOutputFolder[/color] & [color=#3F7F00]theAttachmentName[/color]
						[color=#0000FF][b]save[/b][/color] [color=#3F7F00]theAttachment[/color] [color=#0000FF]in[/color] [color=#3F7F00]theSavePath[/color]
					[b]on[/b] [b]error[/b] [color=#3F7F00]err[/color]
						[color=#0016B0][b]display dialog[/b][/color] [color=#3F7F00]err[/color]
					[b]end[/b] [b]try[/b]
				[b]end[/b] [b]repeat[/b]
			[b]end[/b] [b]repeat[/b]
		[b]end[/b] [b]tell[/b]
	[b]end[/b] [color=#0000FF][b]perform mail action with messages[/b][/color]
[b]end[/b] [b]using terms from[/b][/size][/FONT]

Oder du probierst es mal unter einem anderen Benutzer.
 
Code:
"Macintosh HD:Users:oliverrueckert:Downloads:"

&

Code:
""Macintosh HD:Users:oliverrueckert:Downloads:scan:"

Die beiden habe ich getestet, leider gehts nicht..

Hm, na dann hab ich eben Pech... Bei Dir geht´s?
 
Ja bei mir klappt's ohne Probleme. Was für eine Meldung kommt denn bei dem Skript von Post #31, oder kommt gar keine Meldung?
 
Ok, dann liegt der Fehler entweder bereits in Zeile 1, oder das Skript wird gar nicht erst gestartet. Kannst du die Mail Regel bitte nochmal löschen und neu anlegen, dann folgendes Skript unter /Users/DeinName/Library/Application Scripts/com.apple.mail/ speichern. Beim Anwenden der Regel sollten dann 2 Meldungen kommen.

Code:
[FONT=Verdana][size=2][b]using terms from[/b] [color=#0000FF][i]application[/i][/color] "Mail"
	[b]on[/b] [color=#0000FF][b]perform mail action with messages[/b][/color] [color=#3F7F00]theMessages[/color]
		[color=#0016B0][b]display dialog[/b][/color] "Das Skript läuft."
		[b]try[/b]
			[b]set[/b] [color=#3F7F00]theOutputFolder[/color] [b]to[/b] (([color=#0016B0][b]path to[/b][/color] [color=#261151]home folder[/color]) [b]as[/b] [color=#0000FF][i]string[/i][/color]) & "Downloads:"
		[b]on[/b] [b]error[/b] [color=#3F7F00]err[/color]
			[color=#0016B0][b]display dialog[/b][/color] [color=#3F7F00]err[/color]
		[b]end[/b] [b]try[/b]
		[color=#0016B0][b]display dialog[/b][/color] [color=#3F7F00]theOutputFolder[/color]
		[b]tell[/b] [color=#0000FF][i]application[/i][/color] "Mail"
			[b]repeat[/b] [b]with[/b] [color=#3F7F00]theMessage[/color] [b]in[/b] [color=#3F7F00]theMessages[/color]
				[b]repeat[/b] [b]with[/b] [color=#3F7F00]theAttachment[/color] [b]in[/b] [b]every[/b] [color=#0000FF][i]mail attachment[/i][/color] [b]of[/b] [color=#3F7F00]theMessage[/color]
					[b]try[/b]
						[b]set[/b] [color=#3F7F00]theAttachmentName[/color] [b]to[/b] [color=#6C04D4]name[/color] [b]of[/b] [color=#3F7F00]theAttachment[/color]
						[b]set[/b] [color=#3F7F00]theSavePath[/color] [b]to[/b] [color=#3F7F00]theOutputFolder[/color] & [color=#3F7F00]theAttachmentName[/color]
						[color=#0000FF][b]save[/b][/color] [color=#3F7F00]theAttachment[/color] [color=#0000FF]in[/color] [color=#3F7F00]theSavePath[/color]
					[b]on[/b] [b]error[/b] [color=#3F7F00]err[/color]
						[color=#0016B0][b]display dialog[/b][/color] [color=#3F7F00]err[/color]
					[b]end[/b] [b]try[/b]
				[b]end[/b] [b]repeat[/b]
			[b]end[/b] [b]repeat[/b]
		[b]end[/b] [b]tell[/b]
	[b]end[/b] [color=#0000FF][b]perform mail action with messages[/b][/color]
[b]end[/b] [b]using terms from[/b][/size][/FONT]
 
Leider keine Meldung, habs wie folgt eingegeben:

Code:
using terms from application "Mail"
	on perform mail action with messages theMessages
		display dialog "Das Skript läuft."
		try
			set theOutputFolder to "Users:oliverrueckert:Library:Application Scripts:com.apple.mail:"
		on error err
			display dialog err
		end try
		display dialog theOutputFolder
		tell application "Mail"
			repeat with theMessage in theMessages
				repeat with theAttachment in every mail attachment of theMessage
					try
						set theAttachmentName to name of theAttachment
						set theSavePath to theOutputFolder & theAttachmentName
						save theAttachment in theSavePath
					on error err
						display dialog err
					end try
				end repeat
			end repeat
		end tell
	end perform mail action with messages
end using terms from
 
Das war ein Missverständnis. Am Skript musst du nichts ändern, es muss nur an oben genannter Stelle gespeichert werden.
 
Achso, lol.

Aber nach "...set theOutputFolder to..." muss schon noch der Downloads-Pfad rein oder?

Aber trotzdem nichts....
 
Bildschirmfoto 2012-08-15 um 16.29.32.jpg

Steht jetzt so drin, der Script ist in der Mail Regel auch ausgewählt, beim ausführen der Regel passiert aber leider gar nichts...
 
Zurück
Oben Unten