on composeMail(email_recipient, email_subject, email_content, the_file)
	
	try
		tell application "Sparrow"
			activate
			
			set aMessage to make new outgoing message
			tell aMessage
				set subject to email_subject
				set content to my findAndReplace(return, "
", email_content)
				make new to recipient at beginning with properties {address:email_recipient}
				
				set aAttachment to make new mail attachment with properties {filename:the_file}
				compose
			end tell
		end tell
	end try
	
	
end composeMail


on findAndReplace(tofind, toreplace, TheString)
	set ditd to text item delimiters
	set text item delimiters to tofind
	set textItems to text items of TheString
	set text item delimiters to toreplace
	if (class of TheString is string) then
		set res to textItems as string
	else -- if (class of TheString is Unicode text) then
		set res to textItems as Unicode text
	end if
	set text item delimiters to ditd
	return res
end findAndReplace
