Hey Guys,
I've been messing with a script I found that send out multiple emails to different people. The following script should read the email addresses I want to send the my message to from a .txt file called "address.txt" I got it to work through automator on one system with MAC OS 10.5. But I tested it on another system with 10.4 and I got the following error:
Applescript Error:
Can't make into type file.
Any ideas?
Here is the script, including the automator end tags:
I've been messing with a script I found that send out multiple emails to different people. The following script should read the email addresses I want to send the my message to from a .txt file called "address.txt" I got it to work through automator on one system with MAC OS 10.5. But I tested it on another system with 10.4 and I got the following error:
Applescript Error:
Can't make into type file.
Any ideas?
Here is the script, including the automator end tags:
Code:
on run {input, parameters}
--direct to your plain text file with addresses, and name, tab delimited
set theAddressDOC to read file
("MacintoshHD:Users:test:Movies:address.txt")
set pcount to count paragraphs in theAddressDOC
repeat with i from 1 to number of paragraphs in theAddressDOC
set this_item to paragraph i of theAddressDOC
set Name_text to "" -- set to blank
-- using try so if there is a an error, in this case it will be when the is no name, the script will carry on
-- instead of stopping. The Name_text will reamin as "" if it does
try
--use delimiters (tab) in this case to split the result of this_item and try to set Name_text to the name
set AppleScript's text item delimiters to tab
set para_text to text of this_item
--get the second half of paragraph
set Name_text to text item 2 of para_text
end try
--get the first half of paragraph
set address_text to text item 1 of para_text
--reset the delimiters
set AppleScript's text item delimiters to ""
set theAddress to address_text
-- direct to a doc of what you want the email to say in plain text
set theletter to file
("MacintoshHD:Users:test:Movies:web links body text.txt")
-- What is the subject of the Emails
set theSubject to "Here Are Your Requested Uploaded Links"
-- Check to see if Name_text contains a name or not
if Name_text is "" then
--if no name
set theBody to " you to view" & theletter
else
--the must be a name
set theBody to "Here are the links for " & Name_text & theletter
end if
theBody
-- Choose the account to send the message from
set theSender to "myemail@gmail.com"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content: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
set sender to theSender
make new to recipient at end of to recipients with properties {address:theAddress}
tell content
tell application "Mail"
send newMessage
end tell
-- delay to allow the Mail program to send and not bog down, adjust as needed
delay 10
end tell
end tell
end tell
end repeat
return input
end run