I have a mail script I use to drag & drop a PDF file and send a mail message with the PDF as an attachment. It has worked fine up to the time I installed Safari 5 - now the message has a solid black background over the content and can’t be used. Safari 5 may just be coincidental.
I know the attachment part of the script is the problem.
Does anyone have a better or more correct way to write this script?
Thanks
Here is the script:
on open of finderObjects
set theEntireFileString to finderObjects as string
set theFileString to searchReplace(finderObjects, ":", "/")
set theFileName to Get_file_name(theFileString)
set theJobName to text 1 thru -5 of theFileName
tell application "Mail"
activate
--variables for template message
set theSubject to theJobName
set theRecipient to "abc@xyz.com"
set theCopy to "me@ourcompany.com, you@ourcompany.com"
set theBody to "Greetings," & return & return & "Attached is " & theJobName & "." & return & "Print file(s) also attached." & return & "Print file(s) uploaded to FTP." & return & return & "Please let us know if there's anything else you need, or if any questions arise." & return & return & "Thanks very much," & return & return & "Me" & return & return & "Our Company" & return & "Easy Street" & return & "Our City, ST 12345"
set theAttachment to theEntireFileString as alias
--create message with variables
set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
tell newMessage
set my_recipient to make new to recipient at end of to recipients with properties {address:theRecipient}
set cc_recipient to make new cc recipient at end of cc recipients with properties {address:theCopy}
end tell
tell newMessage
-- visible default is false
set visible to true
if (theAttachment is not equal to "") then
-- position for attachments
make new attachment with properties {file name:theAttachment} at after the last paragraph
end if
end tell
end tell
end open
on searchReplace(origStr, searchStr, replaceStr)
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to searchStr
set origStr to text items of origStr
set AppleScript's text item delimiters to replaceStr
set origStr to origStr as string
set AppleScript's text item delimiters to old_delim
return origStr
end searchReplace
on Get_file_name(x) -- get file name from the string disk:folder:file
set i to length of (x as text)
set y to ""
repeat until character i of (x as text) is ":"
set y to character i of (x as text) & y
set i to i - 1
end repeat
return y
end Get_file_name
Model: G5
AppleScript: 2.0.1
Browser: Safari 533.16
Operating System: Mac OS X (10.5)