Random Sequence

Improves on the built-in Mail PDF workflow from the print dialog by setting the filename & message title to that of the foremost Safari window.

Improved Mail PDF from Safari Script for Mac OS X

Using Script Editor, save this file as ‘Mail from Safari as PDF’ into ~/Library/PDF Services.

The script is accessed using the PDF button in a print dialog.

on open these_items
    try
        tell application "Safari"
            set safari_title to do JavaScript "document.title" in front document
        end tell

        set this_text to "Please find attached a copy of " & safari_title & "

Kind regards,


Johnnie Walker
"   
        tell application "Finder"
            set this_file to item 1 of these_items
            set the name of this_file to (safari_title & ".pdf")
            set theAttchment to this_file as alias
            set this_file_name to the name of this_file
        end tell
        tell application "Mail"
            set newMessage to make new outgoing message with properties {subject:safari_title, content:this_text & return}
            tell newMessage

                tell content
                    make new attachment with properties ¬
                        {file name:theAttchment} at after last paragraph
                end tell

                set visible to true
                activate

            end tell

        end tell
    end try
end open

Sponsored Links: