Does anyone know if its possible to use Applescript to send an email in the background without popping open a new window to send? Its a real pain to automate mail sending when a window pops up to forward email using the script below, especially when typing an email, and the pop up comes up and takes over and what I am typing goes into the To box of the email I want to automatically forward!
Thanks
on run
-- Edit these variables to suit your own Mail account and folders
set emailAccount to "My Email Account" # Name of your email account in Apple Mail
set emailFolder to "Follow Up"
set archiveAccount to "My Email Account" # Name of your email account in Apple Mail to archive the processed mail to
set archiveFolder to "Archive" # Name of your email folder in Apple Mail to archive the processed mail to
-- End of variables editing
send_to_asana(emailAccount, emailFolder, archiveAccount, archiveFolder)
end run
on send_to_asana(emailAccount, emailFolder, archiveAccount, archiveFolder)
tell application "Mail"
set _msgs_to_capture to (every message of mailbox emailFolder of account emailAccount)
repeat with eachMessage in _msgs_to_capture
set theSubject to (subject of eachMessage)
set theContent to the content of eachMessage
set _fwdmsg to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
tell _fwdmsg
make new to recipient at beginning of to recipients with properties {address:"x@mail.asana.com"}
send
end tell
set read status of eachMessage to true
move eachMessage to mailbox archiveFolder of account archiveAccount
end repeat
end tell
end send_to_asana