Copy link to clipboard
Copied
I have an application that will send out a cfmail (3 or 4 lines of content only). If is formatted in a table.
I also have a history log table where every transaction is recorded into a comments field. So when the cfmail is sent, a comment would be inserted into the history table with comments like 'Email sent to customer'. However, this comment is too plain, so they want to put the entire cfmail contents (3 or 4 lines) into the comments field.
How can I do this, including adding the table format/structure, into the comments ?
Copy link to clipboard
Copied
Use cfsavecontent to create a variable with the content. Use that variable for your mail and to update your db.
Copy link to clipboard
Copied
I have a cfsavecontent tag before and after the email content that I wish to capture. However, it is also saving all the table tags, <td> etc., and all the html tags, <br>. etc., plus the stylesheet. I use all that to format the email.
Is there a way to just save the contents itself, without saving all the tags ?
Copy link to clipboard
Copied
There may be a way to preserve the formatting without storing the tags, but it's beyond my expertise.
Copy link to clipboard
Copied
You could capture the formatted mark-up for emailing as you are doing now, then strip out all the mark-up before sticking it in the DB. This can be done fairly easily with a couple of regex replacements. Google these forums, searching for "strip tags". I say "google" rather than "search" because the forum's own search is pretty rubbish, whereas Google does a pretty good job of indexing stuff sensibly.
--
Adam
Copy link to clipboard
Copied
Three rows seem like a reasonable amount of data to dump in the database field, tags and all !. The table tags supply a context, and so represent information worth keeping.
Suppose you've stored the cfsavecontent in the variable, content. Suppose also that you're on Coldfusion 8 or above. Then, you could extract the html table by doing something like
<!--- array of table tags --->
<cfset tableTags=REMatchNoCase("<table\b[^>]*>(.*?)</table>", content)>
<!--- content of the 1st table (the string to be stored in the database) --->
<cfoutput>#tableTags[1]#</cfoutput>
Copy link to clipboard
Copied
Variable REMATCHNOCASE is undefined. | |
The error occurred in E:\devxtroot\RecDisc\unReceivables\forms\dispositionFunction.cfm: line 586 | |
584 : </cfsavecontent> 585 : 586 : <cfset tableTags = REMatchNoCase("<table\b[^>]*>(.*?)</table>", emailContent)> 587 : <cfoutput>#tableTags[1]#</cfoutput> |
I am attemting to use your method and get the error above.
Copy link to clipboard
Copied
It doesn't look like you're on CF8, and reMatch() is new to CF8. You can arrive at the same results using reFind() and mid() and what not.
--
Adam
Copy link to clipboard
Copied
The tags format the email into nice little output with 3 or 4 lines. By stripping out all the html code, will the insert into the db be one long string, since there are no more html tags, or will it be the 3-4 lines, just like the email ?
Copy link to clipboard
Copied
By stripping out all the html code, will the insert into the db be one long string, since there are no more html tags, or will it be the 3-4 lines, just like the email ?
Yes, one string. As I said above, "Three rows seem like a reasonable amount of data to dump in the database field, tags and all !. The table tags supply a context, and so represent information worth keeping."