Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confused on how to submit email based on choice made... 2

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]Ok all,
I'm trying to send an email based on what the user submits.

I originally had two linked field in my data display page sending the user to two separate forms, one for denial and one for approval, but I realize that both forms are updating the same table with a "yes" or "no". (Duh)

Now I don't know how to set up one form where the user will either type yes\no or click a yes\no button and still send my original email (approve and deny) as before. Make sense?
[tt]
"Beware of the most dangerous person in business - the articulate incompetent."
[/tt]

banana.gif
rockband.gif
banana.gif

 
not sure that I got you, but i'll try...

try to use 2 submit buttons - one Yes another No and check in ASP what button was pressed and send them either Approved or Denied... Good Luck! :)
 
[tt]
I know the logic behind it, just don't know the syntax to do it.

Actually I was thinking on providing two radio buttons with values "YES" and "NO" then sumbit the form, but this way, I don't know how to send the proper email. Thanks
[tt]
"Beware of the most dangerous person in business - the articulate incompetent."
[/tt]

banana.gif
rockband.gif
banana.gif

 
If i get what you mean, you have a radio button

<input type=&quot;radio&quot; name=&quot;approved&quot; value=&quot;1&quot; />
<input type=&quot;radio&quot; name=&quot;approved&quot; value=&quot;2&quot; />

with the header Approved and Denied

On the next page

<%
If request(&quot;approved&quot;)=&quot;1&quot; then
' email body text for approved status
else
' email body text for denied
end if
%>
Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
<%
if Request.Form(&quot;radioFieldName&quot;) = &quot;yes&quot;
'send mail Approved
elseif Request.Form(&quot;radioFieldName&quot;) = &quot;no&quot;
'send mail Denied
else
'errorMessage =&quot;Field not selected&quot;
end if
%>

Does it help? Or you need more help? Good Luck! :)
 
[tt]Cool!, I'll try both after lunch. By the looks of it, it's going to work. Thanks fellas. cya after lunch...
[tt]
&quot;Beware of the most dangerous person in business - the articulate incompetent.&quot;
[/tt]

banana.gif
rockband.gif
banana.gif

 
[tt]I'm almost tere

but I'm getting this error when I approve the job:
ERROR
ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.






Code
'populate based on approval*****************
if rsApproved(&quot;request_approval&quot;) = &quot;YES&quot; then
'if approved *********************************
strSubject = &quot;Dear &quot; & rsEmployees(&quot;First&quot;) & &quot;, &quot; & &quot;Your propossed project: &quot; & &quot;&quot;&quot;&quot; & rsApproved(&quot;Request_name&quot;) & &quot;&quot;&quot;&quot; & &quot; has been Approved.&quot;
strBody = &quot;<img src=' & &quot;<br><br>&quot; & &quot;Click <a href=' Proposals</a>&quot; & &quot; to view the entire list. &quot; & &quot;<br><br><br><br>&quot; & &quot;<img src='else
' rsApproved(&quot;request_approval&quot;) = &quot;NO&quot; then
'if denied*************************************
strSubject = &quot;Dear &quot; & rsApproved(&quot;employee_id&quot;) & &quot;, &quot; & &quot;Your propossed project: &quot; & &quot;&quot;&quot;&quot; & rsApproved(&quot;Request_name&quot;) & &quot;&quot;&quot;&quot; & &quot; has been Denied at this time.&quot;
strBody = &quot;<img src=' & &quot;<br><br>&quot; & &quot;Your proposed&quot; & &quot;&quot;&quot;&quot; & rsApproved(&quot;request_name&quot;) & &quot;&quot;&quot;&quot; & &quot; project has been denied at this time. You will be contacted in a timely maner by R & D. Thanks.&quot; & &quot;<br><br><br><br>&quot; & &quot;<img src=' & &quot;
end if
'***********************************************************
[tt]
&quot;Beware of the most dangerous person in business - the articulate incompetent.&quot;
[/tt]

banana.gif
rockband.gif
banana.gif

 
Hi Tony!

This error occurs when you use wrong name of Recordset field. Usually it happens because of misspelling. Just check DataBase fields names and how you call them querying recordset.

In first case you use &quot;Dear &quot; & rsEmployees(&quot;First&quot;)
but in else case you use &quot;Dear &quot; & rsApproved(&quot;employee_id&quot;). Maybe error is here...
Good Luck! :)
 
Is the email code the same as above?
Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
Tony, would you post the entire page code so we'll see where the problem is? Good Luck! :)
 
Yes, I only changed the rsEmployees(&quot;First&quot;) to rsEmployees(&quot;FirstName&quot;)


[tt]
&quot;Beware of the most dangerous person in business - the articulate incompetent.&quot;
[/tt]

banana.gif
rockband.gif
banana.gif

 
I'll post the code, no it's not Eugene, We must've responded our posts at the same time.
[tt]
&quot;Beware of the most dangerous person in business - the articulate incompetent.&quot;
[/tt]

banana.gif
rockband.gif
banana.gif

 
ok, waiting for the code :))
and explain the problem again, as I understand everything is OK except email is not sending on Approve only on Deny, but must be sent in both cases. Am I right? Good Luck! :)
 
As I said b4, when I select the &quot;Deny&quot; radio it send's the email and when I select the &quot;Approve&quot; radio this page just hangs. Thanks in advance fellas.


Code:
[COLOR=green]'********************** EMAL PAGE CODDE ********************** [/color]
<%@LANGUAGE=&quot;VBSCRIPT&quot;%> 
<!--#include file=&quot;Connections/J5.asp&quot; -->
<html>
<title></title>
<body>
<p> 
  <%
Dim rsApproved__MMColParam
rsApproved__MMColParam = &quot;1&quot;
if (Request.QueryString(&quot;id&quot;) <> &quot;&quot;) then rsApproved__MMColParam = Request.QueryString(&quot;id&quot;)
%>
  <%
set rsApproved = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsApproved.ActiveConnection = MM_J5_STRING
rsApproved.Source = &quot;SELECT * FROM dbo.RD_Request WHERE request_id = &quot; + Replace(rsApproved__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;&quot;
rsApproved.CursorType = 0
rsApproved.CursorLocation = 2
rsApproved.LockType = 3
rsApproved.Open()
rsApproved_numRows = 0

reqSender = rsApproved(&quot;employee_id&quot;)

%>
  <%
set rsEmployees = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsEmployees.ActiveConnection = MM_J5_STRING
rsEmployees.Source = &quot;SELECT * FROM dbo.employees where employee_id =&quot; & reqSender
rsEmployees.CursorType = 0
rsEmployees.CursorLocation = 2
rsEmployees.LockType = 3
rsEmployees.Open()
rsEmployees_numRows = 0
%>
  <%
[COLOR=green]'***********************************************************
'create variable to hold message[/color]

Dim objMsg, strFrom, strTo, strSubject, strBody, lngImportance

[COLOR=green]'populate static variables===============================[/color]
strFrom = request.cookies(&quot;user&quot;)(&quot;email&quot;)
strTo = request.cookies(&quot;user&quot;)(&quot;email&quot;)
strFile = &quot;bar.bmp&quot;

[COLOR=green]'populate based on approval*****************[/color]
if rsApproved(&quot;request_approval&quot;) = &quot;YES&quot; then
[COLOR=green]'if approved *********************************[/color]
	strSubject = &quot;Dear &quot; & rsEmployees(&quot;FirstName&quot;) & &quot;, &quot; & &quot;Your propossed project: &quot; & &quot;&quot;&quot;&quot; & rsApproved(&quot;Request_name&quot;) & &quot;&quot;&quot;&quot; & &quot; has been Approved.&quot; 
	strBody = &quot;<img src='[URL unfurl="true"]http://pritstr/j5/randd/images/be.gif'>&quot;[/URL] & &quot;<br><br>&quot; & &quot;Click <a href='[URL unfurl="true"]http://printstr/j5/randd/'>Approved[/URL] Proposals</a>&quot; & &quot; to view the entire list. &quot; & &quot;<br><br><br><br>&quot; & &quot;<img src='[URL unfurl="true"]http://printstr/j5/randd/images/be.gif'>&quot;[/URL] 
else 
[COLOR=green]'if denied*************************************[/color]
if	rsApproved(&quot;request_approval&quot;) = &quot;NO&quot; then
	strSubject = &quot;Dear &quot; & rsEmployees(&quot;FirstName&quot;) & &quot;, &quot; & &quot;Your propossed project: &quot; & &quot;&quot;&quot;&quot; & rsApproved(&quot;Request_name&quot;) & &quot;&quot;&quot;&quot; & &quot; has been Denied at this time.&quot; 
	strBody = &quot;<img src='[URL unfurl="true"]http://printstr/j5/randd/images/be.gif'>&quot;[/URL] & &quot;<br><br>&quot; & &quot;Reason: &quot; & &quot;<br>&quot; & rsApproved(&quot;request_response&quot;) & &quot;<br><br>&quot; & &quot;Please forward all coments and\or questions to Alton Joyner and the R & D team regarding this decision.&quot; & &quot;<br>&quot; & &quot;Thanks.&quot; & &quot;<br><br>&quot; & &quot;<img src='[URL unfurl="true"]http://printstr/j5/randd/images/be.gif'>&quot;[/URL] 
end if
[COLOR=green]'***********************************************************
'create email object****************************************[/color]
Set objMsg = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
[COLOR=green]'populate email object properties with variables created above[/color]
objMsg.From = strFrom
objMsg.To = strTo
objMsg.Subject = strSubject
objMsg.Body = strBody
objMsg.MailFormat = cdoMailFormatMime
objMsg.BodyFormat = cdoBodyFormatHTML

[COLOR=green]'sends the email[/color]
objMsg.Send

Set objMsg = Nothing
%>
  <%
rsApproved.Close()
%>
  <%
rsEmployees.Close()
%>
  <a name=&quot;ovhref&quot; href=&quot;<%=mystring%>&quot;></a> 
  <%
end if
%>
  <script language=&quot;JavaScript&quot;>
ovhref.click()
</script>
</p>
'********************** EMAL PAGE CODDE **********************

[tt]
&quot;Beware of the most dangerous person in business - the articulate incompetent.&quot;
[/tt]

banana.gif
rockband.gif
banana.gif

 
Try this Tony

strsubject= &quot;Dear &quot; & rsEmployees(&quot;FirstName&quot;) & &quot;, &quot; & &quot;Your proposed project: &quot; & rsApproved(&quot;Request_name&quot;)

strbody=&quot;<img src=&quot;&quot;
if rsApproved(&quot;request_approval&quot;) = &quot;YES&quot; then
strsubject=strsubject & &quot; has been Approved.&quot;
strBody = strbody & &quot;Click <a href=&quot;&quot; Proposals</a> to view the entire list. &quot;
else
strSubject =strsubject & &quot; has been Denied at this time.&quot;
strBody = strbody & &quot;Your proposed &quot; & rsApproved(&quot;request_name&quot;) & &quot; project has been denied at this time. You will be contacted in a timely maner by R & D. Thanks.&quot;
end if

strbody=strbody & &quot;<br><br><br><br><img src=&quot;&quot;
I'm assuming you've set the value of the radio buttons correctly. Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
I don't see your radio-buttons (form) anywhere in your code - what's the code on the page that submits to this? This is not a bug - it's an undocumented feature...
;-)
 
Here's the radio buttons form that submits to the email page above.


<form method=&quot;POST&quot; action=&quot;<%=MM_editAction%>&quot; name=&quot;form1&quot;>
<table align=&quot;left&quot; class=&quot;clsNewsDownloadStats&quot; width=&quot;528&quot;>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; width=&quot;141&quot;> </td>
<td width=&quot;383&quot;>
<input type=&quot;hidden&quot; name=&quot;Employee_id&quot; value=&quot;<%=(rsUpdate.Fields.Item(&quot;Employee_id&quot;).Value)%>&quot; size=&quot;32&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; width=&quot;141&quot;> </td>
<td width=&quot;383&quot;>  </td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; width=&quot;141&quot;>Project Name:
</td>
<td width=&quot;383&quot;>
<input type=&quot;hidden&quot; name=&quot;request_name&quot; value=&quot;<%=(rsUpdate.Fields.Item(&quot;request_name&quot;).Value)%>&quot; size=&quot;50&quot;>
<%=rsUpdate(&quot;request_name&quot;)%> </td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; valign=&quot;top&quot; width=&quot;141&quot;>Description:
</td>
<td width=&quot;383&quot;>
<textarea name=&quot;Request_description&quot; cols=&quot;40&quot; rows=&quot;8&quot;><%=(rsUpdate.Fields.Item(&quot;Request_description&quot;).Value)%></textarea>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; width=&quot;141&quot;>Date Requested:
</td>
<td width=&quot;383&quot;>
<input type=&quot;hidden&quot; name=&quot;request_date&quot; value=&quot;<%=(rsUpdate.Fields.Item(&quot;request_date&quot;).Value)%>&quot; size=&quot;32&quot;>
<%=rsUpdate(&quot;request_date&quot;)%> </td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; colspan=&quot;2&quot;>
<div align=&quot;center&quot;></div>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; width=&quot;141&quot;>Project Status:
</td>
<td width=&quot;383&quot;>
<table align=&quot;left&quot; width=&quot;100%&quot; class=&quot;clsNewsDownloadStats&quot;>
<tr>
<td>
'Here are my radio buttons ****************************
<input type=&quot;radio&quot; value=&quot;YES&quot; name=&quot;Request_approval&quot;>
<span class=&quot;clsNewsRating&quot;> Approve it </span>
<td>
</tr>
<tr>
<td>
<input type=&quot;radio&quot; value=&quot;NO&quot; name=&quot;Request_approval&quot;>
<span class=&quot;clsNewsRating&quot;>Deny it</span>
   <font color=&quot;#0000FF&quot; size=&quot;1&quot;><span>(state
reason below)</span></font>
<td>
'Here are my radio buttons ****************************
</tr>
</table>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; valign=&quot;top&quot; width=&quot;141&quot;>Reason(s)
for Denial: </td>
<td width=&quot;383&quot;>
<textarea name=&quot;request_response&quot; cols=&quot;50&quot; rows=&quot;5&quot;></textarea>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot; width=&quot;141&quot;> </td>
<td width=&quot;383&quot;>
<input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;submit&quot;>
<input type=&quot;reset&quot; name=&quot;Reset&quot; value=&quot;Clear&quot;>
</td>
</tr>
</table>
<input type=&quot;hidden&quot; name=&quot;MM_update&quot; value=&quot;true&quot;>
<input type=&quot;hidden&quot; name=&quot;MM_recordId&quot; value=&quot;<%= rsUpdate.Fields.Item(&quot;request_id&quot;).Value %>&quot;>
</form>
[tt]
&quot;Beware of the most dangerous person in business - the articulate incompetent.&quot;
[/tt]

banana.gif
rockband.gif
banana.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top