I’m new to Applescript and I’m trying to create a script that allows a user to enter a file path and then attach that file to a new mail document. I’m having problems with the file path section as Mail doesn’t seem to accept the file path text.
set theName to "SomeOne"
set theAddress to "someone@somewhere.com"
set theSubject to "Mail Subject"
set theBody to "Body Text"
set theAttachment to "OSX HD:User:evan:Desktop:document.pdf"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
tell content
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
end tell
activate
end tell
set theName to "SomeOne"
set theAddress to "someone@somewhere.com"
set theSubject to "Mail Subject"
set theBody to "Body Text"
set theAttachment to "OSX HD:Users:evan:Desktop:document.pdf" as alias
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
tell content
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
end tell
activate
end tell