| | |
<cfmail> question
Please support our ColdFusion advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2006
Posts: 30
Reputation:
Solved Threads: 0
Right now I have a page set up that inserts a record into a DB that a user enterd. I have it set up to take them to another page that shows the the information that they entered. but I also have a cfmail tag that e-mails the same information to their e-mail. the only problem is when it goes to their email it doesn't show up the way I want it to. I want it to be inside of a table but when it shows up in their account it just shows the html tags. the only email client that shows it how I want it to display is hotmail. in gmail and and other accounts it just shows the HTML code.
here is my code
[html]
<cflock name="NewRecordInsert" type="exclusive" timeout="30">
<cftransaction>
<cfquery name="RecordInsert" datasource="Rumors_Forms">
INSERT INTO Bus (Name, Req_Date, Req_Time, Address, Email, PhoneNumber, Reason)
Values('#form.Name#', '#form.Month#/#form.Day#/#form.Year#' ,'#form.Req_Time#','#form.Address#','#form.Email#','#form.PhoneNumber#','#form.Reason#')
</cfquery>
<cfquery name="GetPK" datasource="Rumors_Forms">
SELECT Max(ID) AS MaxID
FROM Bus
</cfquery>
</cftransaction>
</cflock>
<cfquery name="GetRecord" datasource="Rumors_Forms">
SELECT ID, Name, Req_Date, Req_Time, Address, Email, PhoneNumber, Reason
FROM Bus
WHERE ID = #GetPK.MaxID#
</cfquery>
<cfmail query="GetRecord"
from="donotreply@rumorssportsbar.com"
to="#form.Email#"
bcc="ericstauss@gmail.com"
subject="Bus Reservation">
<html>
Here is your information that you entered
<table border="1" cellpadding="0">
<tr>
<th>Confirmation Number</th>
<th>Name</th>
<th>Date</th>
<th>Time</th>
<th>Address</th>
<th>E-mail</th>
<th>Phone Number</th>
<th>Purpose of Rental</th>
</tr>
<cfoutput>
<tr>
<td>#ID#</td>
<td>#Name#</td>
<td>#Req_Date#</td>
<td>#Req_Time#</td>
<td>#Address#</td>
<td>#Email#</td>
<td>#PhoneNumber#</td>
<td>#Reason#</td>
</tr>
</cfoutput>
</table>
Do not loose your confirmation number as you will need to to get the bus, you can also edit your settings with the number
</html></cfmail>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Rumors Bar & Grill | Review Entry</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
th{
background-color: #888888;
}
td {
background-color: #CoCoCo;
}
</style>
</head>
<body>
<div id="page">
<div id="header"><img src="Images/top3.jpg"></div>
<div id="nav" bordercolor="ffffff"> <cfinclude template="navigation.cfm"> </div>
<div id="content" valign="top">
<br>
<table border="1" cellpadding="0">
<h2>The Bus has been reserverd!!</h2>
<h3>Here are the details...</h3>
<tr>
<th>Confirmation Number</th>
<th>Name</th>
<th>Date</th>
<th>Time</th>
<th>Address</th>
<th>E-mail</th>
<th>Phone Number</th>
<th>Purpose of Rental</th>
</tr>
<cfoutput query="GetRecord">
<tr>
<td>#ID#</td>
<td>#Name#</td>
<td>#Req_Date#</td>
<td>#Req_Time#</td>
<td>#Address#</td>
<td>#Email#</td>
<td>#PhoneNumber#</td>
<td>#Reason#</td>
</tr>
</cfoutput>
</table>
</div>
<div id="right" valign="top">and here is extra, maybe an ad or something</div>
<!--<div id="footer">copyright and what not</div>-->
</div>
</body>
</html>
[/html]
here is my code
[html]
<cflock name="NewRecordInsert" type="exclusive" timeout="30">
<cftransaction>
<cfquery name="RecordInsert" datasource="Rumors_Forms">
INSERT INTO Bus (Name, Req_Date, Req_Time, Address, Email, PhoneNumber, Reason)
Values('#form.Name#', '#form.Month#/#form.Day#/#form.Year#' ,'#form.Req_Time#','#form.Address#','#form.Email#','#form.PhoneNumber#','#form.Reason#')
</cfquery>
<cfquery name="GetPK" datasource="Rumors_Forms">
SELECT Max(ID) AS MaxID
FROM Bus
</cfquery>
</cftransaction>
</cflock>
<cfquery name="GetRecord" datasource="Rumors_Forms">
SELECT ID, Name, Req_Date, Req_Time, Address, Email, PhoneNumber, Reason
FROM Bus
WHERE ID = #GetPK.MaxID#
</cfquery>
<cfmail query="GetRecord"
from="donotreply@rumorssportsbar.com"
to="#form.Email#"
bcc="ericstauss@gmail.com"
subject="Bus Reservation">
<html>
Here is your information that you entered
<table border="1" cellpadding="0">
<tr>
<th>Confirmation Number</th>
<th>Name</th>
<th>Date</th>
<th>Time</th>
<th>Address</th>
<th>E-mail</th>
<th>Phone Number</th>
<th>Purpose of Rental</th>
</tr>
<cfoutput>
<tr>
<td>#ID#</td>
<td>#Name#</td>
<td>#Req_Date#</td>
<td>#Req_Time#</td>
<td>#Address#</td>
<td>#Email#</td>
<td>#PhoneNumber#</td>
<td>#Reason#</td>
</tr>
</cfoutput>
</table>
Do not loose your confirmation number as you will need to to get the bus, you can also edit your settings with the number
</html></cfmail>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Rumors Bar & Grill | Review Entry</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
th{
background-color: #888888;
}
td {
background-color: #CoCoCo;
}
</style>
</head>
<body>
<div id="page">
<div id="header"><img src="Images/top3.jpg"></div>
<div id="nav" bordercolor="ffffff"> <cfinclude template="navigation.cfm"> </div>
<div id="content" valign="top">
<br>
<table border="1" cellpadding="0">
<h2>The Bus has been reserverd!!</h2>
<h3>Here are the details...</h3>
<tr>
<th>Confirmation Number</th>
<th>Name</th>
<th>Date</th>
<th>Time</th>
<th>Address</th>
<th>E-mail</th>
<th>Phone Number</th>
<th>Purpose of Rental</th>
</tr>
<cfoutput query="GetRecord">
<tr>
<td>#ID#</td>
<td>#Name#</td>
<td>#Req_Date#</td>
<td>#Req_Time#</td>
<td>#Address#</td>
<td>#Email#</td>
<td>#PhoneNumber#</td>
<td>#Reason#</td>
</tr>
</cfoutput>
</table>
</div>
<div id="right" valign="top">and here is extra, maybe an ad or something</div>
<!--<div id="footer">copyright and what not</div>-->
</div>
</body>
</html>
[/html]
•
•
Join Date: Apr 2006
Posts: 30
Reputation:
Solved Threads: 0
I was just about to update my post. I found that tag and put that in my code. and now it works for every email client except Gmail. I have had HTMl emails sent to my account before and I know they work. Also with those tags there, it works in all other email clients, but now it just shows up as a blank email in Gmail
•
•
Join Date: Jun 2008
Posts: 4
Reputation:
Solved Threads: 0
I have used the cfmail tag alot but dont get the following to work. I have a form were a system administrator can submit a email to all subscribers informing them of 'something', whatever.
My problem is, the text area field is being used for the body of the mail being send via cfmail query
How do I transform the {NAME} inside the textare to the users real name when the cfmail page process the textarea content.
<textarea name="body" cols="30" rows="4" id="body">Dear {NAME}, welcome to our site.</textarea> <-- This gets pass onto the cfmail page for processing?
My problem is, the text area field is being used for the body of the mail being send via cfmail query
How do I transform the {NAME} inside the textare to the users real name when the cfmail page process the textarea content.
<textarea name="body" cols="30" rows="4" id="body">Dear {NAME}, welcome to our site.</textarea> <-- This gets pass onto the cfmail page for processing?
•
•
•
•
I have used the cfmail tag alot but dont get the following to work. I have a form were a system administrator can submit a email to all subscribers informing them of 'something', whatever.
My problem is, the text area field is being used for the body of the mail being send via cfmail query
How do I transform the {NAME} inside the textare to the users real name when the cfmail page process the textarea content.
<textarea name="body" cols="30" rows="4" id="body">Dear {NAME}, welcome to our site.</textarea> <-- This gets pass onto the cfmail page for processing?
ColdFusion Syntax (Toggle Plain Text)
<cfset mailBody = Replace(form.body, "{NAME}", form.name, "all") />
•
•
Join Date: Jun 2008
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
You can string replace the {NAME} with the user's name (which I assume is on a form somewhere). For example:
ColdFusion Syntax (Toggle Plain Text)
<cfset mailBody = Replace(form.body, "{NAME}", form.name, "all") />
-->Form<--
<form id="mail1" name="mail1" method="post" action="test_1.cfm">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td>Subject</td>
<td><label>
<input name="subject" type="text" id="subject" />
<input name="name" type="hidden" value="<cfoutput>#rsSubscribersMail.name#</cfoutput>" />
</label></td>
</tr>
<tr>
<td>From</td>
<td><label>
<input name="from" type="text" id="from" />
</label></td>
</tr>
<tr>
<td>Body</td>
<td><label>
<textarea name="body" cols="30" rows="4" id="body">Hello {NAME}</textarea>
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="Submit" value="Submit" />
</label></td>
</tr>
</table>
</form>
-->CFMail Page<--
<cfquery name="rsSubscribersMail" datasource="DATA">
SELECT subscriber.subscriberID, subscriber.name, subscriber.surname, subscriber.email
FROM subscriber
</cfquery>
<cfset mailBody = Replace(#form.body#, "{NAME}", #rsSubscribersMail.name#, "all") />
<cfmail query="rsSubscribersMail" to="#rsSubscribersMail.email#" from="#form.from#" subject="#form.subject#" server="127.0.0.1" port="25">
#mailBody#
</cfmail>
![]() |
Similar Threads
- Welcome PC Mod Kingdom peeps! (Geeks' Lounge)
- Laptop LCD built into a car? (Monitors, Displays and Video Cards)
- Changing Network Configuration (*nix Software)
Other Threads in the ColdFusion Forum
- Previous Thread: Insert query.
- Next Thread: multiple left outer joins on query of query
| Thread Tools | Search this Thread |
Tag cloud for ColdFusion





