-- This is an Apple Script template.
-- 1) IMPORTANT: first change the extension of this file to .applescript - otherwise it will be overwritten
-- 2) modify the script to support your application



on composeMail(email_recipient, email_subject, email_content, the_file)
	
	tell application "Mail"
		activate
        
        set the_account to first account
        set the_adresses to email addresses of the_account
        set the_adress to item 1 of the_adresses
        set the_font to message font
		set the_font_size to message font size
        if (number of signatures > 0) then
			set the_signature to signature 1
		end if
        
		set the_message to make new outgoing message with properties {subject:email_subject, content:"", visible:true, sender:the_adress}
		tell the_message
			--	make new paragraph at beginning with data return
			make new to recipient at beginning of to recipients with properties {address:email_recipient}
		end tell
		
		tell the_message
			make new attachment at end with properties {file name:the_file}
			set aPara to make new paragraph at beginning with data email_content
            set font of content to the_font
			set size of content to the_font_size
            
            -- important, otherwise signature will disapear again
            delay 1
            
			try
				set message signature to the_signature
			end try

		end tell
	end tell
	
end composeMail