Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Cfmail processing error - what's wrong with my code?

New Here ,
May 08, 2009 May 08, 2009

Hi Everybody,

I am not a tech person but I'll try my best describing the situation.

When I yesterday tried to fix an error message (which always showed when not all requiered fields were filled in at our company's "Request for Quote" site), I think I messed up the whole inquiry-forwarding system. I must have deleted everything.

My company's using Macromedia Dreamwaver 8, and the guy who wrote the pages are long gone. If only I could revert the present non-functioning system how it used to be but it's too late, I already turned my comp off yesterday.

The way it should work is that the customer types in all info we need from him, then pushes the submit button, which then sends an email to us and leads the customer to our "Thank you for your inquiry" page. If some eror happens, it brings the customer to our mailto.cfm page, which now shows some error message I do not understand about the 3rd line, 

variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"RECIPIENT") );

Here's what I found as an old-timer back-up to our mailto.cfm page (which I altered yesterday, and that caused the whole problem), which no longer works either:

<cfscript>
    variable.fieldnames = form.fieldnames;
    variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"RECIPIENT") );
    variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"SUBJECT") );
    variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"THANKURL") );
</cfscript>
<cfparam name="FORM.SUBJECT" default="Web Site Form">
<cfmail to="ouremail@ourdomain.com" from="inforequest@ourdomain.com" subject="#FORM.SUBJECT#">#FORM.SUBJECT#
Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')#

<cfloop index="i" list="#variable.fieldnames#"><cfif len(evaluate("form.#i#"))><cfif uCase(right(i,6)) eq "_BREAK">#chr(13)#</cfif>#ReplaceNoCase(i,"_BREAK","")#:#RepeatString(" ", evaluate(15-len(ReplaceNoCase(i,"_BREAK",""))))# #Replace( evaluate("form.#i#"), chr(10), chr(10) & RepeatString(" ",17), "All" )# #chr(13)#</cfif></cfloop>
</cfmail>

<cflocation url="#form.THANKURL#" addtoken="No">

It seems simple, the to-field is correct, the from-field must be too, why do you still think that it's not forwarding the inquiries as emails any more? Where is this code broken?

I would welcome all suggestions, I really need your help!

5.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , May 13, 2009 May 13, 2009

Ok this is wierd, but your system does not seem to be accepting the line returns in the code.  That is not normal behavior.  But you can hard code them in.

Out of curisoity what type of systems are you working with?

<cfmail
   to="julianna@airengineering.com"
   from="#form.email#"
   subject="#FORM.SUBJECT#">

#FORM.SUBJECT#

Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')##chr(13)##chr(10)#

<cfloop list="#form.fieldnames#" index="field">
<cfif listFindNoCase("RECIPIENT,SUBJECT
...
Translate
Valorous Hero ,
May 12, 2009 May 12, 2009

If you are tryiing the code highlight functionality... Either use the "Syntax Highlighing" function first and then paste the code into the box.  OR paste the code, select it all and then use the "Syntax Highlighting" function.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2009 May 12, 2009

<cfmail

to="julianna@airengineering.com"from="#form.email#"subject="#FORM.SUBJECT#">#FORM.SUBJECT#

Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')#

<cfloop list="#form.fieldnames#" index="field">  <cfif listFindNoCase("RECIPIENT,SUBJECT,THANKURL",field) EQ 0>   </cfif><cfif len(trim(form[field])) GT 0>   #replaceNoCase(field,"_BREAK","")#:
#repeatString(" ",20-len(replaceNoCase(field,"_BREAK","")))#
#replace(form[field],chr(10),chr(10) & repeatString(" ",17),"ALL")#
<cfif uCase(right(field,6)) EQ "_BREAK">#chr(13)#</cfif></cfif></cfloop></cfmail>

<cflocation url="#form.THANKURL#" addtoken="No">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2009 May 12, 2009

<cfmail

to="julianna@domain.com"
from="#form.email#"

subject="#FORM.SUBJECT#">#FORM.SUBJECT#

Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')#

<!--- Loop over all the field in the form.fieldnames list ---><cfloop list="#form.fieldnames#" index="field">  <!--- Skip these field names --->  <cfif listFindNoCase("RECIPIENT,SUBJECT,THANKURL",field) EQ 0>  <!--- NOTE: PUT the exact field name of any form field not to include in the above list --->  <!--- NOTE: If listFindNoCase() returns 0, then this field is not in the list so process it --->  </cfif><!--- If the current form field contains a non-empty string ---><cfif len(trim(form[field])) GT 0>   #replaceNoCase(field,"_BREAK","")#:<!--- output the field name without the string '_BREAK'--->
#repeatString(" ",20-len(replaceNoCase(field,"_BREAK","")))#<!--- Space pad the form field to 20 characters --->
#replace(form[field],chr(10),chr(10) & repeatString(" ",17),"ALL")# <!--- Replace all new line chr(10) characters with a new line and 17 spaces --->
<cfif uCase(right(field,6)) EQ "_BREAK">#chr(13)#</cfif><!--- if the field name contains the string '_BREAK' output a carriage return chr(13) character ---></cfif>
</cfloop></cfmail>

<cflocation url="#form.THANKURL#" addtoken="No">

This is what I'm using now, with breaks. Did this help, does it show colors now?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2009 May 12, 2009

Can't get it right...

You mean punching in two times > and then copying in the code with no enters? That's what I was trying...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 12, 2009 May 12, 2009

New thread to eliminte the indenting again.

Paste your code then select it and the find the "Syntax Highlighting > Plain" function in the above menu that is two blue >> brackets on my screen.

It will produce a display that looks like this.

Alternative you can inclose the text in<pre class="jive_text_macro jive_macro_code" jivemacro="code" ___default_attr="plain"></pre> tags in the plain text input control... click the "HTML" link to get that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 12, 2009 May 12, 2009
<cfmail

to="julianna@airengineering.com"from="#form.email#"subject="#FORM.SUBJECT#">#FO RM.SUBJECT#

Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')#

<cfloop list="#form.fieldnames#" index="field"><cfif listFindNoCase("RECIPIENT,SUBJECT,THANKURL",field) EQ 0><cfif len(trim(form[field])) GT 0>   #replaceNoCase(field,"_BREAK","")#:#repeatString(" ",20-len(replaceNoCase(field,"_BREAK","")))##replace(form[field],chr(10),chr(10) & repeatString(" ",17),"ALL")#<cfif uCase(right(field,6)) EQ "_BREAK">#chr(13)#</cfif></cfif>
</cfif></cfloop>

</cfmail>

<cflocation url="#form.THANKURL#" addtoken="No">

What does this output?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2009 May 12, 2009

Quote Request

Sent Tuesday May 12, 2009 @ 5:52 PM TITLE:               Mr. FIRSTNAME:           test LASTNAME:            rt TITLE2:              df COMPANY:             adf ADDRESS1:            test CITY:                test ZIP:                 123456 PHONE:               TEST PHONE EMAIL:               blabla@blabla.com

No breaks now at all!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 12, 2009 May 12, 2009

Do you have any of your form fields ending in "_BREAK"?

This logic was apparently built contigent on certain fields would be named ending in "_BREAK" so that this code knew where to break the display.

That is what this part of the code is trying to do.

<cfif uCase(right(field,6)) EQ "_BREAK">#chr(13)#</cfif>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 12, 2009 May 12, 2009

Leaving to catch my train in about 10 minutes....

Will check up on this tomorrow.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2009 May 12, 2009

Allright, have a great evening, Ian! Thanks! Looking forward to your comments tomorrow.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2009 May 12, 2009

Well all I understand now is that the code we started today was breaking after every field, which is good, just did not break at the right spot and linked the fields' input with the next field's name, that's all I want to avoid.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 12, 2009 May 12, 2009

Ok then... just take that one long line of code and but one or more breaks between any piece you want a break to occure.

You should be able to see between the different versions how line breaks in the code are translating to line breaks in the email.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 13, 2009 May 13, 2009
<cfmail
   to="julianna@airengineering.com"
   from="#form.email#"
   subject="#FORM.SUBJECT#">

#FORM.SUBJECT#

Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')#

<cfloop list="#form.fieldnames#" index="field">
<cfif listFindNoCase("RECIPIENT,SUBJECT,THANKURL",field) EQ 0><cfif len(trim(form[field])) GT 0>#repeatString(" ",20-len(replaceNoCase(field,"_BREAK","")))#
#replaceNoCase(field,"_BREAK","")#:#replace(form[field],chr(10),chr(10 ) & repeatString(" ",17),"ALL")#</cfif></cfif>
</cfloop>
</cfmail>

<cflocation url="#form.THANKURL#" addtoken="No">

Without seeing your entire application, this is my best guess.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009

Wow isn't it just waaay to early Pacific time? :-)) Good morning! 🙂

I'm gonna give right ahead a shot at it!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 13, 2009 May 13, 2009

Julianna01 wrote:

Wow isn't it just waaay to early Pacific time? :-)) Good morning! 🙂

I'm gonna give right ahead a shot at it!

I work a time shifted shift of 6am to 3:30pm.  I'm quite used to it from my decade in the Culinary industry working mostly breakfast/lunch shifts.

It allows me to get home early for lots of family time.  Also the two or three hours in the morning when the office is mostly empty is some of my most productive of the day!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009

I know exactly what you mean...I'm a European, and at home there's a saying, it goes "Those that get up early, find gold"...

I get up really early too every day, that's when I have time for my personal things, talking to my parents through Skype etc. Then the crazyness starts after 8 when I get to my workplace.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009

It's much better now, the things that belong together stick close to each other now.

I need to go just one step further, so they are not in one continuous line but below each other (starting with the title below the sending date, then below that firstname, below that last name etc...)

Quote Request

Sent Wednesday May 13, 2009 @ 9:37 AM                TITLE:Mr.            FIRSTNAME:TEST             LASTNAME:test               TITLE2:title              COMPANY:company                 CITY:city                STATE:state                  ZIP:12345                EMAIL:test@test.com     COMPRESSORMAKE_1:make    COMPRESSORMODEL_1:model         PARTNUMBER_1:part number

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 13, 2009 May 13, 2009

You need to put the email results into a 'syntax highlight -> plain' block so I can see the actual spacing, not the wrapping the formum inposes on the output.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009

I tried 2 times, why doesn't it show anything? Basically it shows the linked field & input-pairs with some space among each other, I would need those to be line breaks.

I am using Macromedia Dreamweaver 8.0.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 13, 2009 May 13, 2009

Julianna01 wrote:

I tried 2 times, why doesn't it show anything? Basically it shows the linked field & input-pairs with some space among each other, I would need those to be line breaks.

After you create the syntax highlight box paste the email output into it.

I am using Macromedia Dreamweaver 8.0.

That is your editor.  What systems are your web application running on?  Windows|unix, IIS|Appache, etc.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009

That's how I am trying to do it, pasting the email into the box, it';s still not showing....


My op system is Windows XP.

Wait a minute...I just ran your latest code...and..and it seems to have worked!!

The lines are now below each other, even if situated to the left, but are waaaay easier now to read!!

Can you see below?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 13, 2009 May 13, 2009

Julianna01 wrote:

Can you see below?

 

Nope!

Are you seeing the code in the box before you post the message?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009

Yes, I can. I copy the content of the email, create the box, then paste the email into it. Anyways, without the box it does show, hopefully you'll see:

Sent Wednesday May 13, 2009 @ 10:25 AM

               TITLE:Mr.

               EMAIL:test2@test.com

            COMMENTS:Comments here

You can see they are below each other now...I will figure out how I could put an extra line below the date, so it's easier to read, but that's just some esthatical thing.

However, what I found I would definitely need to consult you on is if you have an idea how I could add required fields. Right now anybody who punches in an email address can spam us, and I would need to protect our box so we only receive those inquiries that do contain first-last name, title, city, state etc., a few fields, not all obvoiusly. Any idea?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources