The following Applescript sends an email successfully but does not attach the wav file. Can you tell me what I'm doing wrong? Thank you.
tell application "Mail"
set theSubject to "Voicemail"
set theContent to read (the POSIX path of "/private/tmp/voice.tgCrnv/BODY.txt")
set theAddress to "me@example1.com"
set theSender to "me@example2.com"
set theAttachmentFile to (POSIX file "/private/tmp/voice.tgCrnv/msg_1bb3b4f2-c6b1-4012-89c0-a19177cc6ca2.wav") as string
set msg to make new outgoing message with properties {subject:theSubject, content:theContent, visible:false, sender:theSender}
tell msg to make new to recipient at end of every to recipient with properties {address:theAddress}
tell msg to make new attachment with properties {file name:theAttachmentFile as alias}
send msg
end tell
This work for me
set theSubject to "Voicemail"
set theContent to read "/private/tmp/voice.tgCrnv/BODY.txt"
set theAddress to "me@example1.com"
set theSender to "me@example2.com"
set theAttachmentFile to "/private/tmp/voice.tgCrnv/msg_1bb3b4f2-c6b1-4012-89c0-a19177cc6ca2.wav" as POSIX file as alias
tell application "Mail"
set msg to make new outgoing message with properties ¬
{subject:theSubject, content:theContent, visible:false, sender:theSender}
tell msg
make new to recipient at end of every to recipient with properties {address:theAddress}
make new attachment at end of last character of content with properties ¬
{file name:theAttachmentFile}
end tell
delay 1
send msg
end tell