Eine Antwortmail an alle Absender von markierten Mails
Posted in Applescript, Calendar on Januar 13th, 2008Eine ganz interessante Aufgabenstellung aus einem Forum:
Jemand möchte allen Absendern von in Mail markierten E-Mails antworten ohne dafür extra erst alle in eine Gruppe im Adressbuch zu packen. Es soll also unmittelbar und ohne weiteren Aufwand auf verschiedene Mails verschiedener Absender geantwortet werden können.
-- leere Liste der Empfänger erstellen
set theRecipList to {}
set AppleScript's text item delimiters to ","
tell application "Mail"
-- markierte Mails rausfinden
set a to get selection
-- Anzahl der markierten Mails herausfinden
set theCount to (count of a)
-- Alle gefundenen einzeln abarbeiten
repeat with counter from 1 to theCount
set msg to item counter of a
-- Sender herausfinden
set theSender to sender of msg
-- Mailadresse des Absenders herausfinden und in Variable packen
set theNewRecipient to extract address from theSender
-- in string umwandeln
set b to theNewRecipient as string
-- in die Liste der Empfänger einfügen
copy b to the end of theRecipList
end repeat
set d to every item of theRecipList as string
-- Neue Email in Mail erstellen, Bei Bedarf mit weiteren properties
set newMessage to make new outgoing message -- with properties {subject:theSubject, content:theContent & return & return}
-- Anweisungen an die neu zu erstellende Mail
tell newMessage
-- Mail sichtbar erstellen
set visible to true
-- Absenderadresse angeben. Könnte auch aus einer Variablen kommen.
-- set sender to "test@rechner.local"
-- Empfänger eintragen. Für Blindkopie aus recipients einfach bcc recipients machen.
make new to recipient at end of to recipients with properties {address:d}
-- Bei Bedarf weitere properties
(*
tell content
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
*)
-- Mail in den Vordergrund holen
activate
-- Soll die Nachricht sofort automatisch gesendet werden, nächste Zeile auskommentieren
-- send newMessage
end tell
end tell

