Ich versuche, eine Automator-Ordneraktion zu erstellen, die eine E-Mail mit einer angehängten Datei sendet.
In meinem Ordner werden die Dateien mit der E-Mail als Name generiert: Beispiel: name@company.com.jpg, othername@othercompany.com.jpg und so weiter.
Was ich brauche, ist eine Aktion, die den Dateinamen kopiert, die Erweiterung (.jpg) entfernt, eine E-Mail erstellt und den Dateinamen/die E-Mail in das "An" einfügt und dann die E-Mail sendet.
Ich habe alle eine funktionierende Version, in der die Datei an die E-Mail angehängt und der Inhalt der E-Mail ausgefüllt wird. Aber ich kann keine Lösung finden, um den Dateinamen zu kopieren und ihn an die "To" -Adresse anzugeben.
Hoffe, dass mir da draußen jemand helfen kann :-)
Ich habe es mit Automator versucht, ohne erfolgreich gelöschte Dateien zu durchlaufen.
Hier ist ein Ordneraktionsskript, das das tut, was Sie wollen, und wie Sie es an einen Ordner anhängen:
1. Öffnen Sie den AppleScript-Editor
2. Fügen Sie das folgende Skript in ein neues Dokument ein
property mail_subject : "An image for you"
property mail_plain_content : "Attached you will the image you required." & return & return & "Best Regards" & return & "Automator"
property mail_html_content : "Attached you will the image you required.<br><br>Best Regards<br>Automator"
on adding folder items to this_folder after receiving these_items
processItems(these_items)
end adding folder items to
on processItems(these_items)
repeat with i from 1 to (count of these_items)
set this_item to item i of these_items
if isFolder(this_item) then
processItems(getFolderItems(this_item))
else
processFile(this_item)
end if
end repeat
end processItems
on processFile(this_file)
set mail_address to RemoveExtension(getFileName(this_file))
tell application "Microsoft Outlook"
set newMessage to make new outgoing message with properties {subject:mail_subject, plain text content:mail_plain_content, content:mail_html_content}
tell newMessage
make new recipient with properties {email address:{address:mail_address}}
make new attachment with properties {file:this_file as alias}
send
end tell
activate
end tell
end processFile
on isFolder(this_item)
tell application "System Events" to return (exists folder (this_item as string))
end isFolder
on RemoveExtension(this_name)
-- This function comes from :
-- http://www.macosxautomation.com/applescript/sbrt/index.html
if this_name contains "." then
set this_name to (the reverse of every character of this_name) as string
set dot_offset to the offset of "." in this_name
set this_name to (text (dot_offset + 1) thru -1 of this_name)
set this_name to (the reverse of every character of this_name) as string
end if
return this_name
end RemoveExtension
on getExtension(this_name)
if this_name contains "." then
set this_name to (the reverse of every character of this_name) as string
set dot_offset to the offset of "." in this_name
set this_name to (text 1 thru (dot_offset - 1) of this_name)
set this_name to (the reverse of every character of this_name) as string
return this_name
else
return ""
end if
end getExtension
on getFileName(this_file)
tell application "Finder" to return name of this_file
end getFileName
on getFolderItems(this_folder)
tell application "Finder" to return items of this_folder
end getFolderItems
3. Speichern Sie es in Ihrem Ordner ~/Library/Scripts/Folder Action Scripts
Menü Datei > Speichern
Gehen Sie zum richtigen Ordner: Drücken Sie cmd+ Gund fügen Sie Folgendes ein:
~/Library/Scripts/Folder Action Scripts
und klicken Sie auf Go
Speichern unter: Bild - E-Mail mit Namen als Adresse.scpt (zum Beispiel)
Format: Skript
4. Erstellen Sie einen neuen Ordner, der auf hinzugefügte Elemente überwacht wird
5. Ordnen Sie das Skript dem Ordner zu
Klicken Sie im Finder mit der rechten Maustaste auf Ihren Ordner und wählen Sie dann „ Dienste“ > „Ordneraktionen einrichten“ .
Sie sind fertig, legen Sie eine Datei ab, deren Name eine Adresse ist, die E-Mail wird gesendet.
Bibu
Stefan Johannsen