Carlos Camacho
2005.05.09, 10:56 PM
I have this AppleScript which I use to send email (in a certain format) to MacSurfer when we want to submit news.
tell application "Safari"
set u to URL of document 1 --Safari should be at the page/URL of what you want to submit
--set title to URL of document 1 --Grabs <title> of document. Don't use if <title> is different from article title.
set c to (do JavaScript "getSelection()" in document 1) as string --make sure you've highlighted your title in Safari
end tell
tell application "Mail"
--set sig to signature "your signature" --if you want to add your signature, remove the "--" at beginning of line
--set sig_content to content of sig --also look for the & sig_content below and remove the "--"
set quote to "\""
set msg to make new outgoing message
tell msg
--<begin> Please Do Not Modify This Section <begin>
make new to recipient with properties {name:"Phil Pearson", address:"ppearson@technn.com"}
make new to recipient at end of to recipients with properties {name:"Darren Mahaffy", address:"dmahaffy@macsurfer.com"}
make new cc recipient with properties {name:"Scott Siegling", address:"ssiegling@macsurfer.com"}
--</end> Please Do Not Modify This Section </end>
--For text below: Please only modify text where so noted. Otherwise, please Do Not Modify.
set sender to "Carlos Camacho <editor@idevgames.com>" --replace the text with your information
set subject to "iDevGames: " & quote & c & quote -- or something else that is descriptive
set content to "A story for your consideration ...." & return & return ¬
& "<LI>" & quote & c & quote & return ¬
& "<A HREF=" & quote & u & quote & ">iDevGames</A>" & return ¬
& "<BR>" & return & return ¬
& "----"
--& sig_content -- if you want to add your signature, remove the "--" before the ampersand (&)
tell content of msg
set the size to 12
set the font to "Helvetica"
set the color of every paragraph to {0, 0, 0}
end tell
set visible to true
end tell
activate
end tell
--This script was written by Darren Mahaffy (dmahaffy@macsufer.com), Managing Editor of MacSurfer. Feel free to modify for your use except for the areas marked "Please Do Not Modify".
The output is...
A story for your consideration ....
<LI>""
<A HREF="http://www.google.com/search?client=safari&rls=en&q=pilates&ie=UTF-8&oe=UTF-8">iDevGames</A>
<BR>
----
The script grabs the URL, so it should be able to grab the page's title. I'd like to insert the title in two places.
(1) In the line that sets the Subject...
set subject to "iDevGames: " & quote & c & quote -- or something else that is descriptive
So after "iDevGames:", the page title appears.
(2) In the output, which inserts the following into the email...
<LI>""
Put the title between the quotes.
The above should be trivial, however, I've never done anything with AppleScript. It seems now, you need to highlight the title in Safari in order for it to be inserted. I always forget to do this, so it would be sweet if it just grabbed the page's title. Which 9 out of 10 times is just fine.
Cheers,
tell application "Safari"
set u to URL of document 1 --Safari should be at the page/URL of what you want to submit
--set title to URL of document 1 --Grabs <title> of document. Don't use if <title> is different from article title.
set c to (do JavaScript "getSelection()" in document 1) as string --make sure you've highlighted your title in Safari
end tell
tell application "Mail"
--set sig to signature "your signature" --if you want to add your signature, remove the "--" at beginning of line
--set sig_content to content of sig --also look for the & sig_content below and remove the "--"
set quote to "\""
set msg to make new outgoing message
tell msg
--<begin> Please Do Not Modify This Section <begin>
make new to recipient with properties {name:"Phil Pearson", address:"ppearson@technn.com"}
make new to recipient at end of to recipients with properties {name:"Darren Mahaffy", address:"dmahaffy@macsurfer.com"}
make new cc recipient with properties {name:"Scott Siegling", address:"ssiegling@macsurfer.com"}
--</end> Please Do Not Modify This Section </end>
--For text below: Please only modify text where so noted. Otherwise, please Do Not Modify.
set sender to "Carlos Camacho <editor@idevgames.com>" --replace the text with your information
set subject to "iDevGames: " & quote & c & quote -- or something else that is descriptive
set content to "A story for your consideration ...." & return & return ¬
& "<LI>" & quote & c & quote & return ¬
& "<A HREF=" & quote & u & quote & ">iDevGames</A>" & return ¬
& "<BR>" & return & return ¬
& "----"
--& sig_content -- if you want to add your signature, remove the "--" before the ampersand (&)
tell content of msg
set the size to 12
set the font to "Helvetica"
set the color of every paragraph to {0, 0, 0}
end tell
set visible to true
end tell
activate
end tell
--This script was written by Darren Mahaffy (dmahaffy@macsufer.com), Managing Editor of MacSurfer. Feel free to modify for your use except for the areas marked "Please Do Not Modify".
The output is...
A story for your consideration ....
<LI>""
<A HREF="http://www.google.com/search?client=safari&rls=en&q=pilates&ie=UTF-8&oe=UTF-8">iDevGames</A>
<BR>
----
The script grabs the URL, so it should be able to grab the page's title. I'd like to insert the title in two places.
(1) In the line that sets the Subject...
set subject to "iDevGames: " & quote & c & quote -- or something else that is descriptive
So after "iDevGames:", the page title appears.
(2) In the output, which inserts the following into the email...
<LI>""
Put the title between the quotes.
The above should be trivial, however, I've never done anything with AppleScript. It seems now, you need to highlight the title in Safari in order for it to be inserted. I always forget to do this, so it would be sweet if it just grabbed the page's title. Which 9 out of 10 times is just fine.
Cheers,