Номера | Email | Applescript
Я хотел бы создать электронную таблицу чисел. В этой таблице я хочу указать COL A Email Col B Название города COL C Другое название города и так далее. Я буду вводить эти данные вручную.
Далее я хотел бы, чтобы яблочный скрипт проходил построчно в электронной таблице чисел и отправлял электронное письмо каждому человеку в столбце. Я хотел бы использовать другие переменные в теме или теле письма.
Любая помощь будет оценена! Я новичок в лучшем программист. Я знаю немного Python, но я новичок в AppleScript.
Псевдокод (может быть?)
tell numbers to open spreadsheet
repeat for each line of spreadsheet
tell mail to create email
for address COL A
for subject "Hello (COL B) I need the following Information (COL C)
for email Body "Blah Blah Blah (Col D) blah blah."
send email
end repeat
Функция электронной почты
on email(a, b, c, d)
set recipientName to a
set recipientAddress to b
set theSubject to c & " --> " & d & "Shipment"
set theContent to a & ", if you would like assistance with your shipment moving from " & c & " to " & d & " , or any other shipment you may have, please let me know. We have drivers available in your Area of Operations ready for pick up."
tell application "Mail"
##Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
##Set a recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
##Send the Message
send
end tell
end tell
end email
my email(COL A, COL B, COL C, COL D)
1 ответ
Это то, что я взломал вместе! Я новичок, так что будь нежным. Улучшения и критика очень ценятся!
on email(emails, names, origin, destination)
set recipientName to names
set recipientAddress to emails
set theSubject to "c" & " --> " & "d" & "Shipment"
set theContent to names & ", if you would like assistance with your shipment moving from " & "c" & " to " & "d" & " , or any other shipment you may have, please let me know. We have drivers available in your Area of Operations ready for pick up."
tell application "Mail"
##Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
##Set a recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
##Send the Message
send
end tell
end tell
end email
on recipientNames()
set y to 1 as string
tell application "Numbers"
activate
open alias "Macintosh HD:Users:TYPKRFT:Desktop:Form.numbers"
tell table 1 of sheet 1 of document 1
set myNames to {}
repeat with i from 1 to the count of rows
set x to "B" & y
set myNames to myNames & the value of the cell x
set y to y as integer
set y to y + 1
set y to y as string
end repeat
end tell
end tell
set itemsToDelete to {"missing value", "Name", missing value, "stop"}
set cleanNames to {}
repeat with i from 1 to count myNames
if {myNames's item i} is not in itemsToDelete then set cleanNames's end to myNames's item i
end repeat
return cleanNames
end recipientNames
on emailAddress()
set y to 1 as string
tell application "Numbers"
activate
open alias "Macintosh HD:Users:TYPKRFT:Desktop:Form.numbers"
tell table 1 of sheet 1 of document 1
set myEmails to {}
repeat with i from 1 to the count of rows
set x to "C" & y
set myEmails to myEmails & the value of the cell x
set y to y as integer
set y to y + 1
set y to y as string
end repeat
end tell
end tell
set itemsToDelete to {"missing value", "Email", missing value, "stop"}
set cleanEmails to {}
repeat with i from 1 to count myEmails
if {myEmails's item i} is not in itemsToDelete then set cleanEmails's end to myEmails's item i
end repeat
return cleanEmails
end emailAddress
set a to emailAddress()
set b to my recipientNames()
set reps to count of a
set x to 1
repeat reps times
set emails to item x of a
set names to item x of b
my email(emails, names)
set x to x + 1
end repeat