<!--- Create a structure to hold the message object sent from Flex--->
<cfset messagebody = event.data.body>
<!--- Populate the structure. --->
<cfset mailfrom="#messagebody.emailfrom#">
<cfset mailto="#messagebody.emailto#">
<cfset mailsubject="#messagebody.emailsubject#">
<cfset mailmessage ="#messagebody.emailmessage#">
<!--- Send email with values from the structure. --->
<cfmail from="#mailfrom#"
to="#mailto#"
subject="#mailsubject#">
<cfoutput>#mailmessage#</cfoutput>
</cfmail>
</cffunction>
</cfcomponent>
If the Flex application sends the message in the header instead of in the body, you create and
populate the structure, as the following example shows:
<cfset messageheader = StructNew()>
<cfset messageheader.sendto = event.data.headers.emailto>
<cfset messageheader.sentfrom = event.data.headers.emailfrom>
<cfset messageheader.subject = event.data.headers.emailsubject>
<cfset messageheader.mailmsg = event.data.headers.emailmessage>
<cfset mailfrom="#messageheader.sentfrom#">
<cfset mailto="#messageheader.sendto#">
<cfset mailsubject="#messageheader.subject#">
<cfset mailmessage ="#messageheader.mailmsg#">
Using session and client variables
The Flex Messaging event gateway supports session and client variables. In messages sent from
Flex to ColdFusion through the gateway, the clientID field of the incoming message is the key
to the session. Flex assigns the clientID to the instance of each Flex application.
Using session and client variables
21