applescript / cocoa to create new mail message

Hello, I have a xcode applescript application that gathers data and I need it to (on clicked) create a email message using Mac Mail. I have tried this with applescript using some applescript commands as well as “System Events”. I get about a 50/50 success rate on this.

So I was wondering if somebody could give me some ideas. Here is a snippet of my code where I am gathering the variable and formatting as HTML (I use safari to open, then safari passes to mail to keep my formatting).

on createEmail()
	set receiver to ""
	set theSubject to "Demo Report for " & Scustomer
	set theHtml to "<html>
<body bgcolor=\"#ffffff\">
<BIG><b>Customer Name: </b>" & Scustomer & "</BIG><br><b>Demo Date: </b>" & sDate & "<br><b>Demo Location: </b>" & Slocation & "<br><b>Demo Duration: </b>" & Sduration & "<br><b>Demonstrator: </b>" & Susername & "<br><b>Sales: </b>" & Ssales & "<br><b>Distribution: </b>" & Sdealer & "<br><b>Customer Main Contact: </b>" & Scontact & "<br><b>Additional people present: </b>" & sADDPeople & "<br><b>Products Shown: </b>" & newlist & "<br><b>Comments: </b>" & sComments & "<hr width=\"50%\" size=\"3\" align=\"left\" />
	set myHTML to quoted form of theHtml
	set tempFile to (path to desktop as text) & Scustomer & ".html"
	do shell script "echo " & myHTML & " > " & quoted form of POSIX path of tempFile
	tell application "Safari"
		open file tempFile -- open the html file in safari
		email contents of (get current tab of window 1)
		close window 1
	end tell
	-- delete the temp html file
	delay 1
	do shell script "rm " & quoted form of POSIX path of tempFile
	-- set the info in the mail message
	tell application "Mail"
		make new outgoing message
	end tell
	tell application "System Events"
		tell process "Mail"
			set value of text field 1 of scroll area 2 of window 1 to receiver
			keystroke tab
			keystroke tab
			keystroke tab
			keystroke theSubject
		end tell
	end tell
end createEmail

Any help would be appreciated. I have a feeling that applescript just doesnt have the hooks that it needs for mail. If anybody knows of what language to use or has a example. I would appreciate it.

Model: Mac Book Pro
Browser: Firefox 3.5.10
Operating System: Mac OS X (10.5)

But what doesnt work exactly? For the parts I could make work everything is fine… unfortunately, I don’t have Mail (we use Entourage here in the office) and also the parts where you ask System Events to hit keystrokes is disabled on my computer.

Trying to understand what you are trying to accomplish also…