Skip to main content
Participant
April 6, 2011
Question

CFMail randomly omitting characters

  • April 6, 2011
  • 1 reply
  • 347 views

Having a strange problem with the CFMail tag. It's been going on for some time and our workaround -- manually editing the emails to fix them -- is, well, a workaround. I'd like to just flat out solve this, if possible.

The script is designed to take an HTML form loaded with data, and put it into a machine readable email (with pipe | symbols between each data element), which then gets interpreted by another application. A simple enough use of CFMail.

However, the pipe symbols, despite being outside any CFIF conditionals, are SOMETIMES being flat out omitted from the emails. It's never consistent when and why this happens. I can't see how this is possible; they're within the CFMail tag, they have no code telling them when or when not to show up. Also, sometimes a long text string will wrap to the next line... and have an extra pipe symbol inserted where there shouldn't possibly have been one. How can CFMail insert characters that it was never told to put in the email in the first place?

Here's a sample of the code. I can't post the real thing for proprietary reasons.

<cfmail to="etc@etc.com" from="etc@etc.com" subject="Form Submission">

start|

|#form.namefirst#
|<cfif #form.namemiddle# is "">NULL<cfelse>#form.namemiddle#</cfif>
|#form.namelast#
|#form.birthmonth#
|#form.birthday#
|#val(form.birthyear)#
|#form.degree1#
|#form.degree1month#
|#form.degree1year#
|<cfif #form.degree1institution# is "">NULL<cfelse>#form.degree1institution#</cfif>
|#form.degree2#
|#form.degree2month#
|#form.degree2year#

...

|end</cfmail>

As you see, the only CFIFs in the mix are designed to specify when a text field was left blank, and the pipes are not inside those conditionals.

What's going wrong, here? Hopefully this is enough to go on. Any help would be appreciated.

    This topic has been closed for replies.

    1 reply

    Inspiring
    April 6, 2011

    Maybe try setting type value in your cfmail to text or plain.

    Also you can try using cfsavecontent to a variable and then outputing that variable in the cfmail.

    I've never had issues with cfmail adding or removing charachers so not much help here.