Could someone tell me or show me how to write a script that will take the email that is sent me from the sql database ...
This part is actually a lot harder to do than it seems, because there is a bug involved in Leopard Mail (with the threads in Snow Leopard getting an overhaul I wonder if it's been fixed?).
What you have to do is attach the following script to Mail's Rules (in preferences):
property scrambleit : "Scramble It"
using terms from application "Mail" on perform mail action with messages these_messages for rule this_rule tell application scrambleit to launch end perform mail action with messages end using terms from
Notice what it does is launches a new program. (This gets around the thread issue.)
The program that you launch is actually an Automator Action, which does the following Applescript upon launch:
on run tell application "Mail" try set thesemessages to every message of mailbox "INBOX" of account "Word Scrambler" whose read status is false
repeat with thismessage in thesemessages set read status of thismessage to true
set replyto to reply to of thismessage set originalsubject to subject of thismessage set thewords to content of thismessage
my handle_mail_rule(replyto, originalsubject, thewords) --(sender, subject, message)
end repeat
on error msg number num display dialog msg & " Error number: " end try end tell end run
Depending on your needs, you could also use the line
set thesemessages to every message of mailbox "INBOX" of ccount "Your Account" whose sender contains " email@hidden"
But be careful with this as you'll have to delete each message (after processing), which can be messy if you're not VERY careful
...and put it in a new email and allow me to attach in the body of the email the information they have requested.
This bit is easy (unless you need rtf or html, which is actually a lot more difficult).
tell application "Mail" set outgoingMessage to make new outgoing message with properties { visible: true, sender:" email@hidden", subject:"Your Information", content:"hello world"} end tell
If you want to attach a document instead you would have to add the lines:
tell outemail tell content make new attachment with properties {file name:temppdffile & originalsubject & ".pdf" as alias} at after last paragraph end tell end tell |