Email from ProfitTrain with Sparrow via AppleScript

I use an app called ProfitTrain to handle invoicing my customers and keeping track of expenses.  It works well for my basic needs.

More recently, I switched over to using Sparrow as my mail client.  I’ve noticed since I’ve made the change that it will still pull up my old mail client when I send my invoice to my clients however.  I decided to dig into that and clean that up.

In ProfitTrain, there is an option to install a custom email applescript and when you select it, you are given a basic script which works with the mail app and a few others to work with.  I was able to modify this to get it working.  Below is the code you will need:

-- Script using Sparrow 
on mail_invoice(subject_line, to_name, to_address, attachment_path)     
    tell application "Sparrow" 
        activate 
        set attachmentfilename to (POSIX file attachment_path) as string 
        set myMessage to make new outgoing message with properties {subject:subject_line, content:"Your invoice is attached."} 
        tell myMessage 
            make new to recipient at end of to recipients with properties {name:to_name, address:to_address} 
            make new mail attachment with properties {filename:attachmentfilename as alias} 
            compose 
        end tell 
    end tell 
end mail_invoice

For those less adventurous, you can download the entire script file below.

email_invoice_using_user_script.scpt