I have a script on my server that sends mails using The Mail (Apple) Programme.
It encloses a picture situated on the desktop (the script is larger, where it generates the picture and trashes it afterwards).
Now the picture arrives as an enclosure and I would like it to appear at the end of the text (in other words in the body of the text not as an enclosure). How do I amend the script I have? I have no idea as to how to do this or where to begin. any suggestions are welcome.
Thanks.
set dFolder to "/Users/XYZ/Desktop/"
tell application "Finder" to try
set tFiles to ((every file whose name contains "NameofPNG")) as alias list
on error
set tFiles to ((every file whose name contains "NameofPNG")) as alias as list
end try
set docfolderpath to path to desktop folder as string
set yourfolder to "~/Desktop/" --------- the folder with the documents
set pathtoyourfolder to docfolderpath & yourfolder & ":" as string
set FNDVAR to "NameofPNG" --------"FIND" variable for the files
set ppath to quoted form of POSIX path of pathtoyourfolder
set theSender to "mail@XYZ.com"
set thercpnt to "mail@XYZ.com"
set theFiles to (do shell script "mdfind -onlyin " & "~/Desktop/" & " 'kMDItemDisplayName == \"*" & FNDVAR & "*\"'") ------seems to be faster than finder
set theattachmentspaths to {} ------preparing list for attachment paths
repeat with x from 1 to the count of paragraphs in theFiles
set theF to alias POSIX file (paragraph x of theFiles)
set end of theattachmentspaths to theF
end repeat
tell application "Finder"
set theSubject to short date string of (current date) & (" XYZ")
set theBody to "XYZ"
tell application "Mail"
delay 2
set newMessage to make new outgoing message with properties {address:thercpnt, subject:theSubject, content:theBody & return & return}
tell newMessage
set visible to true
set sender to theSender
make new to recipient at beginning of to recipients with properties {address:thercpnt}
repeat with y from 1 to count of items in theattachmentspaths
delay 2
set theAttachment to item y in theattachmentspaths
tell content
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
delay 2
end repeat
end tell
delay 2
send newMessage
end tell
activate
end tell
AppleScript: 2.3.1
Browser: Safari 537.75.14
Operating System: Mac OS X (10.8)