Hi.
I’m new to AppleScript and these forums.
A project of mine requires saving an image attachment from an email then saving the attachment name and subject to a text file.
The data saved to the text file would be written as “Photo01.jpg::My Vacation”. There seems to be, however, empty characters between each letter. I have to press the arrow key twice to move from one letter to another. This is presenting an issue as the data is then read by a PHP script and cannot be accurately interpreted.
Any help or explanation would be greatly appreciated!
The script I have goes as follows:
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Mail"
set theMessage to last item of theMessages
if theMessage's mail attachments is not {} then
set theSubject to subject of theMessage
set theAttachment to first item of theMessage's mail attachments
set theFileName to "HD:path:path:" & theAttachment's name
try
save theAttachment in theFileName
set the_description_file to "HD:path:path:description.txt"
open for access the_description_file with write permission
write theAttachment's name & "::" & theSubject to file the_description_file starting at eof
close access file the_description_file
on error errnum
end try
end if
end tell
end perform mail action with messages
end using terms from