I have been trying to set up a script that I can send multiple file attachments via email but each attachment is on a single email as I do not have access to FTP on the destination.
I have tried a number of times to attach a document and image to the outgoing mail with no success.
I am using:
Mail.app Version 2.1 (752/752.2)
Applescript 1.10.7
The code used is taken from other solutions that are supposed to work, and each of the following fail to attach to mail.app:
make new mail attachment with properties {name:theAttachment} at after the last paragraph
make new mail attachment with properties {file name:theAttachment} at after the last paragraph
make new attachment with properties {file name:theAttachment} at after the last paragraph
make new attachment with properties {name:theAttachment} at after the last paragraph
Can anyone say why or give me a solution to the issue?
The following is the complete code being used:
[code]property type_list : {“TIFF”, “JPEG”, “PNGf”, “PICT”}
property extension_list : {“tif”, “tiff”, “jpg”, “jpeg”, “png”, “pict”, “pct”}
set theName to “some person”
set theAddress to “destination@somedomain.com”
set sender to “someone@somedomain.com”
– Prompt for message subject
set theResult to display dialog “What would you like the subject of the message to be?” default answer "Photos: "
set theSubject to text returned of theResult
tell application “Finder”
try
set the source_folder to choose folder with prompt “Pick a folder containing the images to process:”
set these_files to every file of the source_folder whose file type is in the type_list or name extension is in the extension_list
set file_count to count of these_files
repeat with i from 1 to the file_count
set theAttachment to (item i of these_files) as string
set theBody to "Photo " & i & " of " & file_count & " attached." & return & "[" & displayed name of item i of these_files & "]"
tell application "Mail"
set everySignature to (name of every signature whose name contains "ODP")
set theSignature to ""
if (count of everySignature) is greater than 0 then
set theSignature to some item of everySignature
end if
set newMessage to make new outgoing message with properties {subject:theSubject, content:return & return & theBody & return & return}
tell newMessage
-- Default is false. Determines whether the compose window will
-- show on the screen or whether it will happen in the background.
set visible to true
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
tell content
make new mail attachment with properties {name:theAttachment} at after the last paragraph
-- make new mail attachment with properties {file name:theAttachment} at after the last paragraph
-- make new attachment with properties {file name:theAttachment} at after the last paragraph
-- make new attachment with properties {name:theAttachment} at after the last paragraph
end tell
end tell
set message signature of newMessage to signature (theSignature)
activate
end tell
end repeat
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
end tell[/code]
Model: Powerbook G4
AppleScript: 1.10.7
Browser: Firefox 2.0.0.7
Operating System: Mac OS X (10.4)