I'm trying to write a CFMail that will email us information about a user in the database. Some fields in the database are optional, and may or may not exist. I'm wondering what the best way to do this in CFMail is.
I have a query that gets information from the database:
<cfquery name="qryGetUser" datasource="#request.SkillsTutorDSN#">
Select FirstName, LastName, EmailAddress, Organization, JobFunction,State, Zip, Street, City, Phone, HowHear, PurchaseDate, Reseller, Customer, SampleLesson, FreeTrial, FreeTrialDate,Join, EWMS
from tbRegistration
where ID=#ID#
</cfquery>
Then, I'd like to email us this information, but only FirstName, LastName, EmailAddress are required fields.
<cfmail to="us@here.com" from="there@there.com" subject="Us">
First Name: #qryGetUser.FirstName#
Last Name: #qryGetUser.LastName#
EmailAddress: #qryGetUser.EmailAddress#
</cfmail>
but I'm wondering how I should get the optional fields into the CFMail. Should I do a bunch of:
<cfif isDefined("qryGetUser.Organization"
>
<cfset OptionalMessage="Organization: " & #qryGetUser.Organization#>
</cfif>
and then add the #OptionalMessage# to the CFMail, or should I do the cfif isDefine's in the CFMail itself?
I have a query that gets information from the database:
<cfquery name="qryGetUser" datasource="#request.SkillsTutorDSN#">
Select FirstName, LastName, EmailAddress, Organization, JobFunction,State, Zip, Street, City, Phone, HowHear, PurchaseDate, Reseller, Customer, SampleLesson, FreeTrial, FreeTrialDate,Join, EWMS
from tbRegistration
where ID=#ID#
</cfquery>
Then, I'd like to email us this information, but only FirstName, LastName, EmailAddress are required fields.
<cfmail to="us@here.com" from="there@there.com" subject="Us">
First Name: #qryGetUser.FirstName#
Last Name: #qryGetUser.LastName#
EmailAddress: #qryGetUser.EmailAddress#
</cfmail>
but I'm wondering how I should get the optional fields into the CFMail. Should I do a bunch of:
<cfif isDefined("qryGetUser.Organization"
<cfset OptionalMessage="Organization: " & #qryGetUser.Organization#>
</cfif>
and then add the #OptionalMessage# to the CFMail, or should I do the cfif isDefine's in the CFMail itself?