Link to home
Start Free TrialLog in
Avatar of mbogert
mbogert

asked on

Problem with cfmail response from end-user

I am working on an employee "vacation request" form, which is currently not using a database.  When the user sends the request, an email is sent to a manager's group mailbox.  The manager then replies to the request using an email form and they get a confirmation pop-up window.  When they submit their response some of the fields are not querying and causing an error.  The odd thing is, it seems to be working fine for some manager's mail clients (all using Outlook 2002), but others are generating an error.  For this reason, I know there must be a setting or update in Outlook that is causing this, but I think there may also be a problem with my code.  I'm new to CF, so there may be other errors or redundancies that do not effect this.  Any help would be greatly appreciated!  This has been driving me crazy!

Here's the initial form code (greatly condensed):.

......
<CFOUTPUT>

<form name="toreq" method="post" action="toreq_out.cfm">

<cfset tod = "email1@domain.com">
<cfset toh = "email2@domain.com">
<cfset tok = "email3@domain.com">
<cfset tot = "email4@domain.com">
<cfset mo=dateformat(now(),"mm")>
<cfset da=dateformat(now(),"dd")>
<cfset yr=dateformat(now(),"yy")>
<cfset hr=timeformat(now(),"HH")>
<cfset mi=timeformat(now(),"mm")>
<cfset se=timeformat(now(),"ss")>

<cfset dateNo=#mo#&#da#&#yr#>
<cfset numNo=#hr#&#mi#&#se#>
<cfset space= "-" >
<cfset formNo=#dateNo#&#space#&#numNo#>

<INPUT type="hidden" name="DN" value = "#dateNo#">
<INPUT type="hidden" name="tod" value = "#tod#">
<INPUT type="hidden" name="toh" value = "#toh#">
<INPUT type="hidden" name="tok" value = "#tok#">
<INPUT type="hidden" name="tot" value = "#tot#">
<INPUT type="hidden" name="FN" value = "#formNo#">
<INPUT type="hidden" name="today" value = "#mo#/#da#/#yr#">
<INPUT type="hidden" name="timenow" value = "#hr#:#mi#">

<input type="text" name="name" size="24">
<input type="text" name="id" size="6">

<select name="center" tabindex="3">
<option value="">---Select---
<option value='DAL'>Dallas
<option value='HOU'>Houston
<option value='KC'>Kansas City
<option value='TUL'>Tulsa
</select>

<input type="text" name="month" maxlength="2" size="2">
<input type="text" name="day" maxlength="2" size="2">
<input type="text" name="year" maxlength="2" size="2">

</form>
</cfoutput>
...



------------------ "toreq_out.cfm" (the second file) -----------------

<cfif #center# eq "DAL">
<cfset to = #tod#>
</cfif>
<cfif #center# eq "HOU">
<cfset to = #toh#>
</cfif>
<cfif #center# eq "KC">
<cfset to = #tok#>
</cfif>
<cfif #center# eq "TUL">
<cfset to = #tot#>
</cfif>

<cfmail from="email@domain.com" to="#to#" type="HTML" subject="#today# #timenow# Time Off Request -- #name# for #month#/#day#/#year#">

<b>REQUEST FOR TIME OFF -- Submitted:&nbsp; #today#&nbsp; Time:&nbsp; #timenow#</b><br>
<hr>
<b>Submitted by:</b> #name#<br>
<br>
<b>Date Requesting:</b> #month#/#day#/#year#<br>

<form action="http:/domain.com/forms/response_toreq.cfm" method="POST" name="send">

<input name="granted" type="radio" value="Approved" checked> APPROVED
<input name="granted" type="radio" value="Denied"> DENIED
Manager: <input type="text" name="manager" size="20">
Date: <input type="text" name="date" size="8">

Reason for Denial: <textarea name="denyreason" rows="2" cols="></textarea>

<input type="submit" name="submit" value="Click here to submit E-Mail response

<INPUT type="hidden" name="to" value = "#to#">
<INPUT type="hidden" name="name" value = "#name#">
<INPUT type="hidden" name="id" value = "#id#">
<INPUT type="hidden" name="center" value = "#center#">
<INPUT type="hidden" name="month" value = "#month#">
<INPUT type="hidden" name="day" value = "#day#">
<INPUT type="hidden" name="year" value = "#year#">
<INPUT type="hidden" name="DN" value = "#DN#">
<INPUT type="hidden" name="today" value = "#today#">
<INPUT type="hidden" name="timenow" value = "#timenow#">

</form>
</cfmail>
......


------------------ "response_toreq.cfm" (the third file) -----------------

.....

<cfmail from="#to#" to="#to#;#id#@domain.com" type="HTML" subject="#today# #timenow# Time Off Request #granted# -- #name# for #month#/#day#/#year#">
Response to Request for Time Off<br>
Request originally sent #today# at #timenow#:
<hr>
<b>Date Requesting:</b>&nbsp;&nbsp; #month#/#day#/#year#<br>
<br><br>
<b>Your request has been #granted#.<br>
<b>Manager:</b>&nbsp;&nbsp; #manager#<br>
<b>Date:</b>&nbsp;&nbsp; #date#<br>
<br>
<b>Reason for Denial (if applicable):</b>&nbsp;&nbsp; #denyreason#</font>
</cfmail>

<cfoutput>
<br><br>
<center>
<font size="6">Your reponse has been sent.</font>
<hr>
<font size="4">A copy of this response will be sent to your group mailbox.<p>
You may close this window.</font>
</center>
</cfoutput>
......

------------------------------------------------------------------

That's it in a nutshell.  Again, all I'm really concerned with is getting the bottom output to generate when the manager submits their response.  On some of their email applications it gives an error while evaluating the expression:  #manager# neq "" and #date# neq "".  Any help would be greatly appreciated!!
Avatar of dlewis9
dlewis9

This is an interesting topic...here's what I've found so far..

When using Outlook Express, you can submit forms from email just fine..

When using Outlook, 2 page requests are sent..one as a POST with the form variables, and one as a plain GET without the form variables.  You see a Cold Fusion error because the form variables are not being sent on the second request.  The first request is either done behind the scenes, or is immediately replaced with the second request so you never see it.

This was tested on Win XP Pro with Office XP....

I'm still looking, but wanted to post that!  Looks like an Outlook bug to me..?
A few things:

First, start using CFSCRIPT when you are setting 3 or more values in a row:

<cfscript>
    tod = "email1@domain.com";
    toh = "email2@domain.com";
    tok = "email3@domain.com";
    tot = "email4@domain.com";
    mo=dateformat(now(),"mm");
    da=dateformat(now(),"dd");
    yr=dateformat(now(),"yy");
    hr=timeformat(now(),"HH");
    mi=timeformat(now(),"mm");
    se=timeformat(now(),"ss");
</cfscript>

Second, start using CFSWITCH instead of your CFIF statements:

<cfswitch expression="#center#">
    <cfcase value="DAL"><cfset to = tod></cfcase>
    <cfcase value="HOU"><cfset to = toh></cfif>
    <cfcase value="KC"><cfset to = tok></cfif>
    <cfcase value="TUL"><cfset to = tot></cfif>
</cfswitch>

Third, You don't need to put pound signs around everything. Only when ouputting a value or sending a value to a CF tag or Custom tag.

Fourth, If you are referring to form variables, use the form scope:

form.manager

Even though using just 'manager' will work, not scoping will produce issues in situations where you might have 2 variables with the same name in different scopes (it's very possible).

Finally, turn on debugging and watch the process at the bottom of the screen. Check to see exactly what form variables are being passed through to each page. If you can't do that (or don't want to) you can alternativly try looping through the Form.FieldNames variable and outputting it's value on each page, something like so:

<cfoutput>#form.fieldNames#<br /></cfoutput>

<cfloop list="#form.fieldNames#" index="fieldName">
  <cfoutput>#fieldName# = #Evaluate("form.#fieldName#")#<br /></cfoutput>
</cfloop>
ASKER CERTIFIED SOLUTION
Avatar of dlewis9
dlewis9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i guess if thigns r working fine for some & NOT for others - then there's ONE possiblity

the other people [for whom it dosent work] may be having text based EMAil client.

u'll need to identify the preferences of people recieving ur mails & ONLY if ur sure they recieve a email in HTML format, u can use <cfmail type="HTML" ... - Else u need to go for plaintext format & make sure u set thigns right by using appropriate HREFs/LINKS on the emails -

i am not sure - but i guess thats what happening above - is it ???

K'Rgds
Anand
Avatar of mbogert

ASKER

dlewis9 and TallerMike:

Thanks very much for your input!  I changed the method to "GET" and this seemed to do the trick for Outlook.  I figured it had something to do with browser settings or a bug, but wanted to be sure.  Also, thanks Mike for the input on making my code more concise and reliable...I'll get the hang of this stuff one of these days.

I'm new to this forum so I'm not sure how the point assigning works.  I had to take dlewis9's answer, because he/she solved my specific problem, but I'd like to send some of the points your way, Mike, for helping me out with the code.  If I figure out how to do it, I'll give you some.  Thanks again for bailing me out of this headache!
mbogert, no problem. To give points to experts, you'll need to setup a question like so:

'Points for #expertName#'

Where expertName is the experts name. Make it worth whatever points you want to give them. The expert should leave a comment thanking you for the points, and you simply choose that response as the answer. It's a little backwards, but it's how it's done!

I suggest that you check out a post that the experts here have all contributed to regarding Cold Fusion Optimization:

https://www.experts-exchange.com/questions/20542979/Cold-Fusion-Optimization-Techniques.html