(**
  *	filename: SharingInvite.applescript
 *
 *)

(* recipientAddress is a list of Addresses to send to
 * messageSubject is the subject of the invite message
 * messageBody is the body of the invite message
 *)
on sendemail(emailer, recipientAddress, messageSubject, messageBody)
	
	(* Part that does all of the work, this works for Mail *)
	if (emailer is equal to "com.apple.mail") then
		tell application "Mail"
			-- Properties can be specified in a record when creating the message or
			-- afterwards by setting individual property values.
			set newMessage to make new outgoing message with properties {subject:messageSubject, content:messageBody}
			tell newMessage
				-- Default is false. Determines whether the compose window will
				-- show on the screen or whether it will happen in the background.
				set visible to true
				
				repeat with emailAddress in recipientAddress
					make new bcc recipient at end of bcc recipients with properties {address:emailAddress}
				end repeat
			end tell
			-- send the message
			--			send newMessage
		end tell
	else
		if (emailer is equal to "com.microsoft.entourage") then
			(* lots of stuff for entourage here *)
		end if
	end if
end sendemail

-- sendemail("com.apple.mail", "dude@apple.com", "messageSubject", "messageBody")
