troubleshooting Question

CF - Send cfmail with email address from session ID

Avatar of JohnMac328
JohnMac328Flag for United States of America asked on
Microsoft SQL Server 2005ColdFusion Language
3 Comments1 Solution875 ViewsLast Modified:
I have a form that sends a thank you note.  It works fine except the from field should have the email of the person that is submitting the form.  I have tried several things but the closest I get is the session.ID appearing in the from field.  I also tried a query within a query but it does not understand what the field is I am referring to.  It is bombing on line 39 in the code window

Variable FROMEMAIL is undefined.  
The error occurred in C:\inetpub\wwwroot\maxibillion_CF\send_thankyou.cfm: line 55
53 : <CFMAIL query="SendResults"
54 :             to="#trim(Toemail) "
55 :             from="#trim(Fromemail) "


Any help is appreciated

<cfparam name="form.employeeID" default="#SESSION.ID#">

<cfif not IsDefined('SESSION.ID')>
  <cflocation url="login.cfm">

<cfquery name="getMembers" datasource="IntranetDB_Coldfusion">
SELECT    ID, last_name, first_name, email_name
FROM  employee_data
ORDER BY last_name, first_name

<cfif structKeyExists(FORM, "submitButton")>

 <cfquery name="Get_To" datasource="IntranetDB_Coldfusion">
SELECT     ID, last_name as ToLast_name, first_name as ToFirst_name, email_name as Toemail
FROM         employee_data
WHERE     (ID = #form.SendThanks#)
   <cfquery name="Get_From" datasource="IntranetDB_Coldfusion">
SELECT     ID, last_name as FromLastname, first_name as FromFirstname, email_name as Fromemail
FROM         employee_data
WHERE  employee_data.ID = '#SESSION.ID#'
    <cfquery name="SendResults" dbtype="query">
SELECT Distinct
   <cfdump var="#form#">
<CFMAIL query="SendResults"
            Subject="Test Results - thanks">
  <table border="0" cellpadding="0" cellspacing="0" style="width:100%; font-family:Arial, Helvetica, sans-serif;">
      <td><p>Dear #SendResults.ToFirst_name#&nbsp;#SendResults.Tolast_name#,
        <p><p>I just wanted to say "#form.reason#".
<body class="twoColElsLtHdr">
<div id="container">
<div id="header"> <img src="images/USGI_Masthead.gif" />
  <div id="mainContent">
    <table class="displayTable">
      <cfform action="send_thankyou.cfm" method="POST" preloader="no">
      <cfinput type="hidden" name="employeeID" value="#employeeID#">

          <th>Send a Thank You</th>
          <td><img src="images/thankyou.gif" width="234" height="144"></td>
          <td>Send To:<br>
            <cfselect name="SendThanks"> <cfoutput query="getMembers">
              <option value="#ID#"> #last_name# ,#first_name#</option>
            </cfoutput> </cfselect>
            Thank you note:<br>
            <cftextarea name="Reason"></cftextarea></td>
          <td><input type="submit" name="submitButton"  value="Submit"></td>

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros