Hi
I would like to send a mail with a path to a file in the body to trigger a script that sends back a mail with the file attached; the following subroutine almost works, except for the line: set theAttachment to (path to “cusr”) & theContent as alias
theSender is the address the mail should be returned to, theContent is a string extracted from the body of the triggering mail containing the last part of the path (“Documents:docname”) to the file I want to have mailed back as an attachment
on sendattachment(theSender, theContent)
tell application "Mail"
activate
try
set theSubject to (path to "cusr") & theContent as string -- yields the correct complete path to the file
set theAttachment to (path to "cusr") & theContent as alias -- (gives an error, can't figure out the correct syntax)
set myMessage to make new outgoing message with properties {subject:theSubject, content:"voilà " & return}
tell myMessage
make new to recipient at end of to recipients with properties {address:theSender}
tell content
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
end tell
send myMessage
end try
end tell
end sendattachment
It works fine if I replace “set theAttachment to (path to “cusr”) & theContent as alias” by "set the theAttachment to (path to “cusr”) & “Documents:docname” as alias
Any ideas
TIA