cfmail using cfset
Hi everyone,
I've been racking my brain on this for hours and I still haven't been able to figure it out. I feel like it should be fairly simple.
I've got a form that asks a user for an email address. When the form is submitted, the data is sent to an email address. If the user gives an email address, I want the recipient to be able to reply by hitting "reply" in their email client. Here's my code:
<cfoutput>
<cfif '#Form.EmailAddress#' neq ''>
<cfset EmailFrom = '#Form.FirstName# #Form.LastName#<#Form.EmailAddress#>'><cfelse>
<cfset EmailFrom = '#Form.FirstName# #Form.LastName#'>
</cfif>
</cfoutput>
<cfmail to="recipient" from="#EmailFrom#" subject="Appointment Request">
Everything's working at about 75%. If a user provides an email address, the form process works perfectly. However, if the user does not provide an email address, I simply want the "from" field in the email to output the first and last name. If not email address is provided, the process still works, but the first and last names are not output in the email "from" field. I get "<unknown sender>".
Does anyone have suggestions? I also tried a cfif statement in the cfmail string, but CF throws an error when I try to the run the script.
Thanks!
