Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFMail Question 1

Status
Not open for further replies.

dasniper

Programmer
Apr 11, 2001
25
0
0
US
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=&quot;qryGetUser&quot; datasource=&quot;#request.SkillsTutorDSN#&quot;>
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=&quot;us@here.com&quot; from=&quot;there@there.com&quot; subject=&quot;Us&quot;>
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(&quot;qryGetUser.Organization&quot;)>
<cfset OptionalMessage=&quot;Organization: &quot; & #qryGetUser.Organization#>
</cfif>
and then add the #OptionalMessage# to the CFMail, or should I do the cfif isDefine's in the CFMail itself?
 
Do your ifs inside the CFMail tag or outside and reference the assigned variables inside the CFMail tag. It's your call, it doesn't realy matter. ----------------------------------------
Is George Lucas Kidding...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top