I am trying to create an automatic reply script. The Mail rule that calls the script functions properly, based on the subject of the mail message. The sender can request either a .doc or a .pdf (or both) of a particular document to be sent to him/her. I set up the main body of the script to decide what information to send to the handler to format and send the appropriate reply with the desired attachment(s). I have read through this thread, and thought I understood how to properly address the location of the document(s) to attach, but it will not work. I think that is my main problem; I know where the files are (my Mail Downloads folder of my Library), and I know their names, but I cannot get the syntax correct to make those file(s) into attachemnts.
Any assistance or commentary is appreciated.
--Automatically reply to any Mail message with 'spep' in the subject line(via Mail rule) and reply to that sender with appropriate attachment(s)
using terms from application "Mail"
on perform mail action with messages The_Messages
tell application "Mail" to repeat with This_Message in The_Messages
set new_recip to This_Message's sender
if (get This_Message's subject) contains "doc" then
my MakeReply(new_recip, {"Whatever.doc"})
else
if (get This_Message's subject) contains "pdf" then
my MakeReply(new_recip, {"Whatever.pdf"})
else
my MakeReply(new_recip, {"Whatever.doc", "Whatever.pdf"})
end if
end if
end repeat
end perform mail action with messages
end using terms from
----------------------------------------------------------
to MakeReply(send_er, atts) --remember that [atts] may be a list of two items
set att_path to (path to library folder as Unicode text) & "Mail Downloads:"
tell application "Mail"
set b to make new outgoing message with properties {sender:"xxx@xxx.com", subject:"SPEP Reply"}
tell b to make new to recipient
set content of b to ("X Committee" & return & return)
try--Nothing in this try block functions.
repeat with att_ment in atts
set i to ((att_path & att_ment))
tell b's content
make new attachment with properties {file name:i as alias} at after the last paragraph of content
end tell
end repeat
end try
set address of first to recipient of b to send_er
send b
end tell
end MakeReply