Mail soll Anhänge bestimmter Mails sofort drucken

macchrissli

Celler Dickstiel
Registriert
21.05.05
Beiträge
803
Hallo,

ich kann leider kein Applescript, ist es möglich einen script zu schreiben der als rule angewendet werden kann bei bestimmten mails eines empfängers sofort die anhänge (word dokumente, pdfs und powerpoint präsentationen) zu öffnen und zu drucken?

MFG Chriss
 

Daisy

Uelzener Rambour
Registriert
14.01.06
Beiträge
366
Hallo,

ich kann leider kein Applescript, ist es möglich einen script zu schreiben der als rule angewendet werden kann bei bestimmten mails eines empfängers sofort die anhänge (word dokumente, pdfs und powerpoint präsentationen) zu öffnen und zu drucken?

MFG Chriss

Hallo Chriss,

ich würde die Aufgabe teilen in ein Mail-Script, das die Attachments in einem Ordner temporär sichert und eine an diesen Ordner angehängte Ordneraktion, die die Files, die dort landen, druckt und anschließend gleich wieder löscht. In etwa so:

Mailscript:
Code:
property attFolder : "path:to:the:printfolder:" -- hier bitte einen sinnvollen Pfad einfügen ;-)

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		repeat with msg in theMessages
			tell application "Mail" to set theAttachments to mail attachments of msg
			repeat with thisAtt in theAttachments
				tell application "Mail" to set attName to (name of thisAtt)
				set uniqueAttName to my uniqueSaveName(attName, attFolder)
				tell application "Mail" to save thisAtt in (attFolder & uniqueAttName)
			end repeat
		end repeat
	end perform mail action with messages
end using terms from

on uniqueSaveName(fileName, destFolder)
	set uniqueName to fileName
	if (my existsFile(destFolder & uniqueName)) then
		set {od, text item delimiters} to {text item delimiters, "."}
		set fNameParts to text items of fileName
		set suffix to 0
		if ((count of fNameParts) > 1) then
			set fNameBase to (text items 1 thru -2 of fNameParts) as text
			set fNameExtension to text item -1 of fNameParts
			repeat while my existsFile(destFolder & uniqueName)
				set suffix to suffix + 1
				set uniqueName to (fNameBase & "_" & suffix & "." & fNameExtension)
			end repeat
		else
			repeat while my existsFile(destFolder & uniqueName)
				set suffix to suffix + 1
				set uniqueName to (fileName & "_" & suffix)
			end repeat
		end if
	end if
	return uniqueName
end uniqueSaveName

on existsFile(thisFile)
	try
		get alias thisFile
		return true
	on error
		return false
	end try
end existsFile


Ordneraktion:
Code:
on adding folder items to thisFolder after receiving addedItems	
	repeat with thisItem in addedItems
		tell application "Finder"
			try
				print thisItem
				delete thisItem
			on error errMsg
				display dialog "Ein Fehler ist aufgetreten:" & return & errMsg
			end try
		end tell
	end repeat
end adding folder items to

Ist das so, wie du es wolltest?

Grüße,

Daisy