Jeff, the sort of thing you can do with Applescript is only limited to the rich text letters you prepare.
• Create two .png images of your header & footer, and save them in the folder, calling them 'Header.png' & 'Footer.png'
• Write your letter in rich text, using Pages or whatever, and save it as a rich text file called 'Todays Letter', inside the 'Todays Letter' folder.
• Place whatever attachments you require in the 'Attachments' folder.
Run the script below.
global Todaysletter
global PathToDesktop
global PathToAttachments
global PathToLetterFolder
global ErrorTrap
global TheColoredText
global MainMailRecipient
global ReportBCCRecepients
set TheColoredText to {"This is todays update.", "Please help!"}
set ReportBCCRecepients to {"Jeff Gold <
email@hidden>"}
--<-- needs to come from somewhere
set Todaysletter to "Todays Letter"
set PathToDesktop to path to desktop
set PathToLetterFolder to PathToDesktop & Todaysletter as text
set PathToAttachments to PathToLetterFolder & ":Attachments" as text
set ErrorTrap to {}
my SendDailyReport()
on SendDailyReport()
set TheDate to current date
set the_subject to "Animal Welfare Report. " & day of TheDate & " " & month of TheDate & " " & year of TheDate & "."
set the_content to my SetTheContent()
set TheContent to return
try
set LogoPath1 to PathToLetterFolder & ":Header.png" as text
set LogoPath1 to POSIX path of LogoPath1
on error
say "error with header"
set LogoPath1 to ""
end try
try
set LogoPath2 to PathToLetterFolder & ":Footer.png" as text
set LogoPath2 to POSIX path of LogoPath2
on error
say "error with footer"
set LogoPath2 to ""
end try
tell application "Mail"
activate
repeat with x from 1 to count of windows
--close window x
end repeat
end tell
tell application "Mail"
activate
set NewMessage to make new outgoing message with properties {address:MainMailRecipient, subject:the_subject, content:TheContent}
tell NewMessage
try
repeat with themailitem in MainMailRecipient
make new to recipient at end of to recipients with properties {address:themailitem}
end repeat
end try
try
repeat with themailitem in ReportBCCRecepients
make new bcc recipient at end of bcc recipients with properties {address:themailitem}
end repeat
end try
set visible of NewMessage to true
tell application "System Events" to tell process "Mail"
repeat 6 times
keystroke tab
end repeat
keystroke return
end tell
try
tell application "System Events" to tell process "Mail"
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
end tell
on error errmsg
display dialog errmsg
end try
try
make new attachment with properties {file name:LogoPath1} at before the first paragraph
end try
try
make new attachment with properties {file name:LogoPath2} at after the last paragraph
end try
tell application "Finder"
set TempAttachments to every file of folder PathToAttachments as list
end tell
repeat with EachAttachment in TempAttachments
try
set theShortName to name of EachAttachment
set thePath to PathToAttachments & ":" & theShortName
set AttachmentPath to POSIX path of thePath as text
set the last character to the last character & return & return & return
make new attachment with properties {file name:AttachmentPath} at after the last paragraph
on error
set end of ErrorTrap to "Attachment"
end try
end repeat
end tell
--send
end tell
end SendDailyReport
on SetTheContent()
try
tell application "TextEdit"
activate
open ((PathToLetterFolder & ":" & "Todays Letter.rtf") as text)
tell application "System Events" to tell process "TextEdit"
click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1
end tell
quit
end tell
on error
set end of ErrorTrap to "Letter body"
end try
return the clipboard
end SetTheContent