Description
NetNewsWire is still my RSS Reader of choice -- in part due to it's scriptability! When I started using Microsoft Outlook 2011 as my default email program, one of the things that I missed was being able to send the full contents of NetNewsWire items to people (currently only an option if you're using Apple Mail). This script lets me do that easily. And if you add a keyboard shortcut using FastScripts, you'll enjoy extra shmoove-ness! ;)Important Notes
- This AppleScript requires Outlook 2011 SP1 or Greater (Version 14.1.0+)
- If you do not have GROWL installed, you'll currently get an "GrowlHelperApp" error. I think I have a fix for this and -- if you're interested in testing it -- please send me a message with the Contact Form or a note to the Veritrope.com Twitter account.
The Code
(*
http://veritrope.com
NetNewsWire to Microsoft Outlook
Version 1.0
April 18, 2011
Project Status, Latest Updates, and Comments Collected at:
http://veritrope.com/code/netnewswire-to-microsoft-outlook-mail-contents
// IMPORTANT NOTES
- This AppleScript requires Outlook 2011 SP1 or Greater (Version 14.1.0+)
- If you do not have GROWL installed, you'll currently get an "GrowlHelperApp" error. I think I have a fix for this and -- if you're interested in testing it -- please send me a message:
1.) With the Veritrope.com Contact Form, located at http://veritrope.com/about-veritrope/contact/, or
2.) Via the Veritrope.com Twitter account -- @Veritrope
// CHANGELOG:
1.00 INITIAL RELEASE
// INSTALLATION:
Just drop it into the NetNewsWire Script Folder!
FastScripts Installation (Optional, but recommended):
--Download and Install FastScripts from http://www.red-sweater.com/fastscripts/index.html
--Copy script or an Alias to ~/Library/Scripts/Applications/NetNewsWire
--Set up your keyboard shortcut
*)
(*
======================================
// USER SWITCHES
======================================
*)
--CURRENTLY NONE
(*
======================================
// OTHER PROPERTIES
======================================
*)
property the_Item : ""
property the_Title : ""
property processnames : {}
(*
======================================
// MAIN PROGRAM
======================================
*)
--CHECK FOR GROWL
my myGrowl()
--GET INFO FROM NNW
tell application "NetNewsWire"
try
--IS IT A TAB OR A HEADLINE?
if (index of selected tab is not 0) then
--IT'S A TAB!
set the_Type to "tab"
set urlsList to URLs of tabs
set ixCurrentTab to index of selected tab
set titleList to titles of tabs
set the_Item to (item (ixCurrentTab + 1) of urlsList)
set the_Title to (item (ixCurrentTab + 1) of titleList)
set the_URL to the_Item
set the_Item to my get_Page(the_Item)
set dispName to "NetNewsWire "
--CREATE THE MESSAGE IN OUTLOOK
set the_Message to my outlook_Create(the_Title, the_Item, the_Type, dispName, the_URL)
my growl_Notify(the_Title)
--IT'S A HEADLINE!
else if exists selectedHeadline then
set the_Headline to selectedHeadline
set the_Type to "headline"
set the_Item to ""
set dispName to (display name of subscription of selectedHeadline)
set the_URL to (URL of selectedHeadline)
set the_Title to (title of selectedHeadline)
--CREATE THE MESSAGE IN OUTLOOK
if exists (description of selectedHeadline) then
set the_Item to (description of selectedHeadline)
set the_Message to my outlook_Create(the_Title, the_Item, the_Type, dispName, the_URL)
else
set the_Item to my get_Page(the_URL)
set the_Message to my outlook_Create(the_Title, the_Item, the_Type, dispName, the_URL)
end if
--GROWL RESULTS
my growl_Notify(the_Title)
else
if "GrowlHelperApp" is in processnames then
tell application "GrowlHelperApp" -- GROWL FAILURE FOR NO SELECTION
notify with name ¬
"Failure Notification" title ¬
"No Headline or Tab Selected!" description ¬
"Please Select An Item And Try Again." application name "NetNewsWire to Microsoft Outlook"
end tell
else if "GrowlHelperApp" is not in processnames then -- NON-GROWL ERROR MSG. FOR NO SELECTION
display dialog "No headline or tab selected!" with icon 0
end if
end if
(* ERROR HANDLING *)
on error errText number errNum
if "GrowlHelperApp" is in processnames then
tell application "GrowlHelperApp" -- GROWL FAILURE FOR ERROR
notify with name ¬
"Failure Notification" title ¬
"Message Failure" description "Failed To Send " & the_Title & ¬
" Due To The Following Error: " & return & errText ¬
application name "NetNewsWire to Microsoft Outlook"
end tell
else if "GrowlHelperApp" is not in processnames then -- NON-GROWL ERROR MSG. FOR ERROR
display dialog "Item Failed to Import: " & errNum & return & errText with icon 0
end if
end try
end tell
(*
======================================
// HANDLER SUBROUTINES
======================================
*)
--CHECK / REGISTER GROWL
on myGrowl()
tell application "System Events"
set processnames to name of every process
end tell
if "GrowlHelperApp" is in processnames then
tell application "GrowlHelperApp"
set the allNotificationsList to {"Success Notification", "Failure Notification"}
set the enabledNotificationsList to {"Success Notification", "Failure Notification"}
register as application ¬
"NetNewsWire to Microsoft Outlook" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Microsoft Outlook"
end tell
end if
end myGrowl
--GET THE WEBPAGE DATA
on get_Page(the_Item)
set rawItem to do shell script "curl -siL " & (quoted form of the_Item)
set the_code to items 10 thru 12 of rawItem as string
--ON ERROR
if the_code is greater than 400 then
display dialog "ERROR"
else
--STRIP HEADER
set oldDelim to AppleScript's text item delimiters
set newDelim to "<head>"
set AppleScript's text item delimiters to newDelim
set theItem to second text item of rawItem
set AppleScript's text item delimiters to oldDelim
return theItem
end if
end get_Page
--CREATE THE OUTGOING MESSAGE IN OUTLOOK
on outlook_Create(the_Title, the_Item, the_Type, dispName, the_URL)
set the_Title to "Article from " & dispName & "-- " & the_Title
set the_Item to "<h3>Original Link: </h3>" & the_URL & "<hr>" & the_Item
tell application "Microsoft Outlook" -- CREATE HTML MAIL FROM HEADLINE
set newmessage to make new outgoing message with properties {subject:the_Title, content:the_Item}
open newmessage
activate
end tell
end outlook_Create
--GROWL SUCCESS
on growl_Notify(the_Title)
if "GrowlHelperApp" is in processnames then -- GROWL SUCCESS
tell application "GrowlHelperApp"
notify with name ¬
"Success Notification" title ¬
"Message Created!" description ¬
"Successfully created " & the_Title & ¬
" in Microsoft Outlook" application name "NetNewsWire to Microsoft Outlook"
end tell
end if
end growl_Notify
http://veritrope.com
NetNewsWire to Microsoft Outlook
Version 1.0
April 18, 2011
Project Status, Latest Updates, and Comments Collected at:
http://veritrope.com/code/netnewswire-to-microsoft-outlook-mail-contents
// IMPORTANT NOTES
- This AppleScript requires Outlook 2011 SP1 or Greater (Version 14.1.0+)
- If you do not have GROWL installed, you'll currently get an "GrowlHelperApp" error. I think I have a fix for this and -- if you're interested in testing it -- please send me a message:
1.) With the Veritrope.com Contact Form, located at http://veritrope.com/about-veritrope/contact/, or
2.) Via the Veritrope.com Twitter account -- @Veritrope
// CHANGELOG:
1.00 INITIAL RELEASE
// INSTALLATION:
Just drop it into the NetNewsWire Script Folder!
FastScripts Installation (Optional, but recommended):
--Download and Install FastScripts from http://www.red-sweater.com/fastscripts/index.html
--Copy script or an Alias to ~/Library/Scripts/Applications/NetNewsWire
--Set up your keyboard shortcut
*)
(*
======================================
// USER SWITCHES
======================================
*)
--CURRENTLY NONE
(*
======================================
// OTHER PROPERTIES
======================================
*)
property the_Item : ""
property the_Title : ""
property processnames : {}
(*
======================================
// MAIN PROGRAM
======================================
*)
--CHECK FOR GROWL
my myGrowl()
--GET INFO FROM NNW
tell application "NetNewsWire"
try
--IS IT A TAB OR A HEADLINE?
if (index of selected tab is not 0) then
--IT'S A TAB!
set the_Type to "tab"
set urlsList to URLs of tabs
set ixCurrentTab to index of selected tab
set titleList to titles of tabs
set the_Item to (item (ixCurrentTab + 1) of urlsList)
set the_Title to (item (ixCurrentTab + 1) of titleList)
set the_URL to the_Item
set the_Item to my get_Page(the_Item)
set dispName to "NetNewsWire "
--CREATE THE MESSAGE IN OUTLOOK
set the_Message to my outlook_Create(the_Title, the_Item, the_Type, dispName, the_URL)
my growl_Notify(the_Title)
--IT'S A HEADLINE!
else if exists selectedHeadline then
set the_Headline to selectedHeadline
set the_Type to "headline"
set the_Item to ""
set dispName to (display name of subscription of selectedHeadline)
set the_URL to (URL of selectedHeadline)
set the_Title to (title of selectedHeadline)
--CREATE THE MESSAGE IN OUTLOOK
if exists (description of selectedHeadline) then
set the_Item to (description of selectedHeadline)
set the_Message to my outlook_Create(the_Title, the_Item, the_Type, dispName, the_URL)
else
set the_Item to my get_Page(the_URL)
set the_Message to my outlook_Create(the_Title, the_Item, the_Type, dispName, the_URL)
end if
--GROWL RESULTS
my growl_Notify(the_Title)
else
if "GrowlHelperApp" is in processnames then
tell application "GrowlHelperApp" -- GROWL FAILURE FOR NO SELECTION
notify with name ¬
"Failure Notification" title ¬
"No Headline or Tab Selected!" description ¬
"Please Select An Item And Try Again." application name "NetNewsWire to Microsoft Outlook"
end tell
else if "GrowlHelperApp" is not in processnames then -- NON-GROWL ERROR MSG. FOR NO SELECTION
display dialog "No headline or tab selected!" with icon 0
end if
end if
(* ERROR HANDLING *)
on error errText number errNum
if "GrowlHelperApp" is in processnames then
tell application "GrowlHelperApp" -- GROWL FAILURE FOR ERROR
notify with name ¬
"Failure Notification" title ¬
"Message Failure" description "Failed To Send " & the_Title & ¬
" Due To The Following Error: " & return & errText ¬
application name "NetNewsWire to Microsoft Outlook"
end tell
else if "GrowlHelperApp" is not in processnames then -- NON-GROWL ERROR MSG. FOR ERROR
display dialog "Item Failed to Import: " & errNum & return & errText with icon 0
end if
end try
end tell
(*
======================================
// HANDLER SUBROUTINES
======================================
*)
--CHECK / REGISTER GROWL
on myGrowl()
tell application "System Events"
set processnames to name of every process
end tell
if "GrowlHelperApp" is in processnames then
tell application "GrowlHelperApp"
set the allNotificationsList to {"Success Notification", "Failure Notification"}
set the enabledNotificationsList to {"Success Notification", "Failure Notification"}
register as application ¬
"NetNewsWire to Microsoft Outlook" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Microsoft Outlook"
end tell
end if
end myGrowl
--GET THE WEBPAGE DATA
on get_Page(the_Item)
set rawItem to do shell script "curl -siL " & (quoted form of the_Item)
set the_code to items 10 thru 12 of rawItem as string
--ON ERROR
if the_code is greater than 400 then
display dialog "ERROR"
else
--STRIP HEADER
set oldDelim to AppleScript's text item delimiters
set newDelim to "<head>"
set AppleScript's text item delimiters to newDelim
set theItem to second text item of rawItem
set AppleScript's text item delimiters to oldDelim
return theItem
end if
end get_Page
--CREATE THE OUTGOING MESSAGE IN OUTLOOK
on outlook_Create(the_Title, the_Item, the_Type, dispName, the_URL)
set the_Title to "Article from " & dispName & "-- " & the_Title
set the_Item to "<h3>Original Link: </h3>" & the_URL & "<hr>" & the_Item
tell application "Microsoft Outlook" -- CREATE HTML MAIL FROM HEADLINE
set newmessage to make new outgoing message with properties {subject:the_Title, content:the_Item}
open newmessage
activate
end tell
end outlook_Create
--GROWL SUCCESS
on growl_Notify(the_Title)
if "GrowlHelperApp" is in processnames then -- GROWL SUCCESS
tell application "GrowlHelperApp"
notify with name ¬
"Success Notification" title ¬
"Message Created!" description ¬
"Successfully created " & the_Title & ¬
" in Microsoft Outlook" application name "NetNewsWire to Microsoft Outlook"
end tell
end if
end growl_Notify