473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ASP/SQL/Email Question

14
Bare with me guys. I will try and make this short and to the point. I have a website that allows students to check their admission status by submitting their email address which in turn sends them and our admissions office an email regarding their status in our SQL database. The ASP script that runs pulls all information from one table.

There are three possible status types; 'AC (App Complete), AI (App Incomplete), and UR (Under Review)'. If a student happens to be tagged as AC or UR an email is sent letting him or her know their status.

Now if the student is listed as AI, the email generated should list fields that have not been completed (described below in the code). As of right now the email is generated and sent, although fields are never listed. Just a blank space beneath "You are currently missing:".

I threw in some response.write statements to ensure data was being pulled from the database, which it appears to be doing.

Setup: Website (FrontPage), SQL 2005, MS Access 2003

Any suggestions would be great. Thanks!

Expand|Select|Wrap|Line Numbers
  1. <% @LANGUAGE = VBScript %>
  2. <%
  3. Option Explicit
  4. Response.Expires = -1
  5. Dim Applicant
  6. Set Applicant = Request.Form("txtEmailAddress")
  7. Dim objRS
  8. Dim strQuery
  9. Set Session("DB") = Server.CreateObject("ADODB.Connection")
  10.     Session("DB").Open("OSC")
  11.  
  12. strQuery = "SELECT First_Name, Citizenship, College_1, College_2, College_3, GRE_Score_Date, TOEFLScore, "
  13. strQuery = strQuery & "Transcript_1_Date, Transcript_2_Date, Transcript_3_Date, Reference__1, Reference__2, Reference_3, Reference_4, "
  14. strQuery = strQuery & "Letter_1_Date, Letter_2_Date, Letter_3_Date, Letter_4_Date, ApplicationStatus "
  15. strQuery = strQuery & "FROM tblAdmissionsData WHERE Email = '" & Applicant & "';"
  16.  
  17. Set objRS = Session("DB").Execute(strQuery)
  18.  
  19. If objRS.EOF = TRUE Then
  20. response.write ("<p align='center'><a target='_self' href='http://www.college.edu'>")
  21. response.write ("<img alt='College' src='images/Banner.jpg' border='0'></a></p>")
  22. response.write ("There is no record with that email address in the database.")
  23. Else
  24.  
  25. Dim FName
  26. Set FName = objRS(0)
  27. Dim Citizen
  28. Set Citizen = objRS(1)
  29. Dim College1
  30. Set College1 = objRS(2)
  31. Dim College2
  32. Set College2 = objRS(3)
  33. Dim College3
  34. Set College3 = objRS(4)
  35. Dim GRE
  36. Set GRE = objRS(5)
  37. Dim TOEFL
  38. Set TOEFL = objRS(6)
  39. Dim Tran1
  40. Set Tran1 = objRS(7)
  41. Dim Tran2
  42. Set Tran2 = objRS(8)
  43. Dim Tran3
  44. Set Tran3 = objRS(9)
  45. Dim Ref1
  46. Set Ref1 = objRS(10)
  47. Dim Ref2
  48. Set Ref2 = objRS(11)
  49. Dim Ref3
  50. Set Ref3 = objRS(12)
  51. Dim Ref4
  52. Set Ref4 = objRS(13)
  53. Dim RefLtr1
  54. Set RefLtr1 = objRS(14)
  55. Dim RefLtr2
  56. Set RefLtr2 = objRS(15)
  57. Dim RefLtr3
  58. Set RefLtr3 = objRS(16)
  59. Dim RefLtr4
  60. Set RefLtr4 = objRS(17)
  61. Dim AdStatus
  62. Set AdStatus = objRS(18)
  63.  
  64. Dim Body
  65. Dim Mail
  66. Set Mail = CreateObject("CDONTS.NewMail")
  67. Mail.From = "user@college.edu"
  68. Mail.To = Applicant
  69. Mail.Bcc = "helpdesk@college.edu"
  70. Mail.Subject = "Your Admission Status"
  71.  
  72. Body = Body & "Greetings " & FName & "!" & vbCRLF & vbCRLF
  73. Select Case AdStatus
  74.     case "AC"
  75.         Body = Body & "Your application to the College has been received and is complete." & vbCRLF
  76.     case "AI"
  77.         Body = Body & "Your application has been received but is incomplete." & vbCRLF
  78.         Body = Body & "You are currently missing:" & vbCRLF & vbCRLF
  79.             'GRE Report
  80.                 If IsNull(GRE) Then
  81.                 Body = Body & "GRE Score Report" & vbCRLF
  82.                 Else
  83.                 End If
  84.             'TOEFL Score
  85.                 If Citizen <> "USA" AND IsNull(TOEFL) Then
  86.                 Body = Body & "TOEFL Score" & vbCRLF
  87.                 Else
  88.                 End If
  89.             'Reference Letters
  90.                 If Citizen = "USA" Then 'Main loop
  91.                     If IsNull(RefLtr1) AND IsNull(RefLtr2) Then
  92.                     Body = Body & "2 Reference Letters" & vbCRLF
  93.                     ElseIf IsNull (RefLtr2) Then
  94.                     Body = Body & "A Reference Letter has been received from " & Ref1 & ". One additional letter is required." & vbCRLF
  95.                     End If
  96.                 Else 'Main loop
  97.                     If IsNull(RefLtr1) AND IsNull(RefLtr2) Then
  98.                     Body = Body & "2 Reference Letters" & vbCRLF
  99.                     ElseIf IsNull(RefLtr2) Then
  100.                     Body = Body & "A Reference Letter has been received from " & Ref1 & ". One additional letter is required." & vbCRLF
  101.                     End If
  102.                 End if 'Main loop
  103.             'Transcripts
  104.                 If (IsNull(College1)=FALSE) AND IsNull(Tran1) Then
  105.                 Body = Body & "Transcript for " & College1 & vbCRLF
  106.                 Else
  107.                 End If
  108.                 If (IsNull(College2)=FALSE) AND IsNull(Tran2) Then
  109.                 Body = Body & "Transcript for " & College2 & vbCRLF
  110.                 Else
  111.                 End If
  112.                 If (IsNull(College3)=FALSE) AND IsNull(Tran3) Then
  113.                 Body = Body & "Transcript for " & College3 & vbCRLF
  114.                 Else
  115.                 End If
  116.         Body = Body & vbCRLF & "Please note the deadline for submission of all application materials for international applicants is December 1." & vbCRLF
  117.     case "UR"
  118.         Body = Body & "Your application to the College has been forwarded to the Admissions Committee for review." & vbCRLF
  119.     case else
  120.         Body = Body & "No application has been received." & vbCRLF
  121. End Select
  122. Body = Body & vbCRLF & "Thank you," & vbCRLF & vbCRLF & "User" & vbCRLF & "The Program" & vbCRLF & "The College" & vbCRLF & "College" & vbCRLF & "user@college.edu"
  123. Mail.Body = Body
  124. Mail.Send
  125. set Mail = nothing
  126. %>
  127.  
  128. <html>
  129. <head>
  130. <meta http-equiv="Content-Language" content="en-us">
  131. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  132. <title>Status Result</title>
  133. </head>
  134. <body>
  135. <p align="center"><a target="_self" href="http://www.college.edu">
  136. <img alt="The College" src="http://www.college.edu/images/Banner.jpg" border="0"></a></p>
  137. <br>
  138. <font face="arial, sans serif,helvetica" size="2"><p>
  139. <%
  140. response.write (FName)
  141. response.write (",<br><br>")
  142. response.write ("Your admission status has been emailed to you at ")
  143. response.write (Applicant)
  144. objRS.close
  145. Session("DB").close
  146. Set objRS = Nothing
  147. Set Session("DB") = Nothing
  148. Set FName = Nothing
  149. Set Citizen = Nothing
  150. Set College1 = Nothing
  151. Set College2 = Nothing
  152. Set College3 = Nothing
  153. Set GRE = Nothing
  154. Set TOEFL = Nothing
  155. Set Tran1 = Nothing
  156. Set Tran2 = Nothing
  157. Set Tran3 = Nothing
  158. Set Ref1 = Nothing
  159. Set Ref2 = Nothing
  160. Set Ref3 = Nothing
  161. Set Ref4 = Nothing
  162. Set RefLtr1 = Nothing
  163. Set RefLtr2 = Nothing
  164. Set RefLtr3 = Nothing
  165. Set RefLtr4 = Nothing
  166. Set AdStatus = Nothing
  167.  
  168. End If
  169. %>
  170. </p>
  171. <p>
  172. Thank you,<br>
  173. College <br>
  174. Office of Admissions<br>
  175. <a href="mailto:user@college.edu?subject=Admissions">user@college.edu</a><br>
  176. <a href="http://www.college.edu"</a></p>
  177. </font></body>
  178. </html>
Feb 20 '08 #1
12 1590
markrawlingson
346 Expert 100+
I would use something like the following..


Expand|Select|Wrap|Line Numbers
  1. For Each oField In oRs.Fields
  2.    If IsNull( oRs( oField ) ) Then
  3.       sEmailMessage = sEmailMessage & oField & VbCrLf
  4.    End If
  5. Next
  6.  
This is of course assuming that you're allowing null values for the fields which are missing information. Then you can just run through each of the fields in your table, checking to see which ones are empty, and write the field's name out.

Sincerely,
Mark
Feb 20 '08 #2
bpw22az
14
Mark, I appreciate the reply. My concern using the code below is I am only looking for particular null fields depending on which case is valid, ie 'AC', 'AI', and 'UR'.

Something weird to add actually: I noticed as I placed response.write statements for each field (Citizen, GRE, etc) the emails started populating as they should. The only thing now is if you leave the write statements, students see a nice long string of information across the top of the webpage that also lets them know an email has been sent regarding their status.

Any ideas? :) Thanks.


I would use something like the following..


Expand|Select|Wrap|Line Numbers
  1. For Each oField In oRs.Fields
  2.    If IsNull( oRs( oField ) ) Then
  3.       sEmailMessage = sEmailMessage & oField & VbCrLf
  4.    End If
  5. Next
  6.  
This is of course assuming that you're allowing null values for the fields which are missing information. Then you can just run through each of the fields in your table, checking to see which ones are empty, and write the field's name out.

Sincerely,
Mark
Feb 20 '08 #3
jhardman
3,406 Expert 2GB
Something weird to add actually: I noticed as I placed response.write statements for each field (Citizen, GRE, etc) the emails started populating as they should. The only thing now is if you leave the write statements, students see a nice long string of information across the top of the webpage that also lets them know an email has been sent regarding their status.

Any ideas? :) Thanks.
The simple way to solve that problem is to put your response.write statements in html comment tags:
Expand|Select|Wrap|Line Numbers
  1. response.write "<!-- pulled studentName from DB: " & objRS("studentName") & " -->" & vbNewLine
but I would be surprised if that was really what had solved the problem... Are you sure nothing else changed when you added the response.write statements?

Jared
Feb 21 '08 #4
bpw22az
14
It has been a very strange problem. I have basically gotten to the point where the email will send with the null fields just fine. Although now if I try to run the code with a Select Case statement the email will show up without the fields listed. Here is my last post:


The email seems to work, although when using the case statement to determine the status it will not place the null fields in the email. The email goes out just fine for all, but is missing the null fields when I add the Select Case code.
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Applicant
  3. Set Applicant = Request.Form("txtEmailAddress")
  4. Dim oRs, oField, fieldCount, FName, Status
  5. Set oRs = Server.CreateObject("ADODB.Recordset")
  6. oRs.Open "vwAcademicsAdmissionsData WHERE Email = '" & Applicant & "';","DSN=OSC"
  7. Set FName = oRs("First_Name")
  8. Set Status = oRs("ApplicationStatus")
  9.  
  10. Select Case Status
  11. case "AI"
  12. sMsg = sMsg & "Greetings " & FName & "!" & vbCRLF & vbCRLF
  13. sMsg = sMsg & "Your application to the College has been received." & vbCRLF & vbCRLF
  14. sMsg = sMsg & "Any missing items on your application are listed below:" & vbCRLF & vbCRLF
  15. For Each oField In oRs.Fields
  16. If IsNull( oRs( oField.name ) ) Then
  17. sMsg = sMsg & oField.name & VbCrLf
  18. End If
  19. Next
  20. End Select
  21. Dim Mail
  22. Set Mail = CreateObject("CDONTS.NewMail")
  23. Mail.From = "user1@college.edu"
  24. Mail.To = Applicant
  25. Mail.Bcc = "user@college.edu"
  26. Mail.Subject = "Your Admission Status"
  27. Mail.Body = sMsg
  28. Mail.Send
  29.  
  30. oRs.Close
  31. Set oRs = Nothing
  32. %>
Feb 21 '08 #5
jhardman
3,406 Expert 2GB
A similar approach to Mark's, but using the specific responses you had already programmed:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Option Explicit
  3. Response.Expires = -1
  4. Dim Applicant
  5. Applicant = Request.Form("txtEmailAddress")
  6. Dim objRS
  7. Dim strQuery
  8. Set Session("DB") = Server.CreateObject("ADODB.Connection")
  9.     Session("DB").Open("OSC")
  10.  
  11. strQuery = "SELECT * FROM tblAdmissionsData WHERE Email = '" & Applicant & "';"
  12.  
  13. Set objRS = Session("DB").Execute(strQuery)
  14.  
  15. If objRS.EOF = TRUE Then %>
  16.    <p align='center'><a target='_self'  href='http://www.college.edu'><img
  17.     alt='College' src='images/Banner.jpg' border='0'></a></p>
  18.    There is no record with that email address in the database.
  19. <%
  20. Else
  21.  
  22. Dim Body
  23. Dim Mail
  24. Set Mail = CreateObject("CDONTS.NewMail")
  25. Mail.From = "user@college.edu"
  26. Mail.To = Applicant
  27. Mail.Bcc = "helpdesk@college.edu"
  28. Mail.Subject = "Your Admission Status"
  29.  
  30. Body = Body & "Greetings " & objRS("FName") & "!" & vbCRLF & vbCRLF
  31. Select Case objRS("AdStatus")
  32.     case "AC"
  33.         Body = Body & "Your application to the College has been received and is complete." & vbCRLF
  34.     case "AI"
  35.         Body = Body & "Your application has been received but is incomplete." & vbCRLF
  36.         Body = Body & "You are currently missing:" & vbCRLF & vbCRLF
  37.             'GRE Report
  38.                 If IsNull(objRS("GRE")) Then
  39.                 Body = Body & "GRE Score Report" & vbCRLF
  40.                 Else
  41.                 End If
  42.             'TOEFL Score
  43.                 If objRS("Citizen") <> "USA" AND IsNull(objRS("TOEFL")) Then
  44.                 Body = Body & "TOEFL Score" & vbCRLF
  45.                 Else
  46.                 End If
  47.             'Reference Letters
  48.                 If objRS("Citizen") = "USA" Then 'Main loop
  49.                     If IsNull(objRS("RefLtr1")) AND Then
  50.                     Body = Body & "2 Reference Letters" & vbCRLF
  51.                     ElseIf IsNull (objRS("RefLtr2")) Then
  52.                     Body = Body & "A Reference Letter has been received from " & objRS("Ref1") & ". One additional letter is required." & vbCRLF
  53.                     End If
  54.                 Else 'Main loop
  55.                     If IsNull(objRS("RefLtr1")) Then
  56.                     Body = Body & "2 Reference Letters" & vbCRLF
  57.                     ElseIf IsNull(objRS("RefLtr2")) Then
  58.                     Body = Body & "A Reference Letter has been received from " & objRS("Ref1") & ". One additional letter is required." & vbCRLF
  59.                     End If
  60.                 End if 'Main loop
  61.             'Transcripts
  62.                 If isNull(objRS("College1"))=FALSE AND IsNull(objRS("Tran1")) Then
  63.                 Body = Body & "Transcript for " & objRS("College1") & vbCRLF
  64.                 Else
  65.                 End If
  66.                 If isNull(objRS("College2"))=FALSE AND IsNull(objRS("Tran2")) Then
  67.                 Body = Body & "Transcript for " & objRS("College2") & vbCRLF
  68.                 Else
  69.                 End If
  70.                 If isNull(objRS("College3"))= FALSE AND IsNull(objRS("Tran3")) Then
  71.                 Body = Body & "Transcript for " & College3 & vbCRLF
  72.                 Else
  73.                 End If
  74.         Body = Body & vbCRLF & "Please note the deadline for submission of all application materials for international applicants is December 1." & vbCRLF
  75.     case "UR"
  76.         Body = Body & "Your application to the College has been forwarded to the Admissions Committee for review." & vbCRLF
  77.     case else
  78.         Body = Body & "No application has been received." & vbCRLF
  79. End Select
  80. Body = Body & vbCRLF & "Thank you," & vbCRLF & vbCRLF & "User" & vbCRLF & "The Program" & vbCRLF & "The College" & vbCRLF & "College" & vbCRLF & "user@college.edu"
  81.  
Let me know if this helps.

Jared
Feb 22 '08 #6
jhardman
3,406 Expert 2GB
It has been a very strange problem. I have basically gotten to the point where the email will send with the null fields just fine. Although now if I try to run the code with a Select Case statement the email will show up without the fields listed. Here is my last post:


The email seems to work, although when using the case statement to determine the status it will not place the null fields in the email. The email goes out just fine for all, but is missing the null fields when I add the Select Case code.
Sorry, I must have started typing my second response before your last was posted, I hope it isn't confusing. You adapted Mark's code correctly. There must be a line or two missing here, I assume you truncated the code. Why not change this to an if...then...else statement rather than a SELECT CASE? you only have three different possibilities for status, right?
Feb 22 '08 #7
bpw22az
14
I actually did try switching from Select Case to If/Then/Else. Same result. Yep, three possiblities. AC, AI, and UR are the three codes in the Status database field.

So strange. The email will be populated with the null fields just fine when testing with a user that has the AI (Incomplete) status in my database, although I will test the same user with the Select Case or If Then Else statements added, and I will receive the same email without the fields listed.

:)



Sorry, I must have started typing my second response before your last was posted, I hope it isn't confusing. You adapted Mark's code correctly. There must be a line or two missing here, I assume you truncated the code. Why not change this to an if...then...else statement rather than a SELECT CASE? you only have three different possibilities for status, right?
Feb 22 '08 #8
jhardman
3,406 Expert 2GB
I actually did try switching from Select Case to If/Then/Else. Same result. Yep, three possiblities. AC, AI, and UR are the three codes in the Status database field.

So strange. The email will be populated with the null fields just fine when testing with a user that has the AI (Incomplete) status in my database, although I will test the same user with the Select Case or If Then Else statements added, and I will receive the same email without the fields listed.

:)
try something like this pseudo code:
[code]response.write status

if status = ai
response.write all the null fields, use the loop or whatever
elseif status = ac
response.write all complete
else
response.write in review
end if [code]it sure looks like the problem is in the select case or if statement, not in the emailing, so try the above just to check if the if statement is executing at all.

Jared
Feb 22 '08 #9
bpw22az
14
Ok, gave the response.write a go with If/Then/Else statements. Sure enough, the null fields are displayed on the web-page although they are missing from the email. It appears the data is there for the taking, but will not transfer with the email when using Select Case or If/Then/Else.

Any ideas? :) (Code I used is below)
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Applicant
  3. Set Applicant = Request.Form("txtEmailAddress")
  4. Dim oRs, oField, fieldCount, strQuery
  5. Set Session("DB") = Server.CreateObject("ADODB.Connection")
  6.     Session("DB").Open("OSC")
  7.  
  8. strQuery = "SELECT First_Name, Citizenship, College_1, College_2, College_3, GRE_Score_Date, TOEFLScore, "
  9. strQuery = strQuery & "Transcript_1_Date, Transcript_2_Date, Transcript_3_Date, Reference__1, Reference__2, Reference_3, Reference_4, "
  10. strQuery = strQuery & "Letter_1_Date, Letter_2_Date, Letter_3_Date, Letter_4_Date, ApplicationStatus "
  11. strQuery = strQuery & "FROM vwAcademicsAdmissionsData WHERE Email = '" & Applicant & "';"
  12.  
  13. Set oRS = Session("DB").Execute(strQuery)
  14.  
  15. Dim FName
  16. Set FName = oRS(0)
  17.  
  18.         sMsg = sMsg & "Greetings " & FName & "!" & vbCRLF & vbCRLF
  19.         sMsg = sMsg & "Your application to the College has been received." & vbCRLF & vbCRLF
  20.  
  21.     IF ApplicationStatus = AI Then
  22.  
  23.         sMsg = sMsg & "Any missing items on your application are listed below:" & vbCRLF & vbCRLF
  24.         For Each oField In oRs.Fields
  25.         If IsNull( oRs( oField.name ) ) Then
  26.         Response.Write(oField.name)
  27.         End If
  28.         Next
  29.  
  30.     Else If ApplicationStatus = AC Then
  31.         Response.Write("Your application is complete")
  32.  
  33.     Else
  34.         Response.Write("Under Review")
  35.         End If
  36.  
  37.  
  38.         sMsg = sMsg & vbCRLF & "Please note the deadline for submission of all application materials for international applicants is December 1." & vbCRLF
  39.         sMsg = sMsg & vbCRLF & "Thank you," & vbCRLF & vbCRLF & "Test User" & vbCRLF & "Academic Programs" & vbCRLF & "College" & vbCRLF & "user@college.edu"
  40.  
  41. Dim Mail
  42. Set Mail = CreateObject("CDONTS.NewMail")
  43. Mail.From = "user@college.edu"
  44. Mail.To = Applicant
  45. Mail.Bcc = "helpdesk@college.edu"
  46. Mail.Subject = "Your Admission Status"
  47. Mail.Body = sMsg
  48. Mail.Send
  49. set Mail = nothing
  50. %> 
  51. <html>
  52. <head>
  53. <meta http-equiv="Content-Language" content="en-us">
  54. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  55. <title>Status Result</title>
  56. </head>
  57. <body>
  58. <p align="center"><a target="_self" href="http://www.college.edu">
  59. <img alt="College" src="http://www.college.edu/images/BannerHome1.jpg" border="0"></a></p>
  60. <br>
  61. <font face="arial, sans serif,helvetica" size="2"><p>
  62. <%
  63. response.write (FName)
  64. response.write (",<br><br>")
  65. response.write ("Your admission status has been emailed to you at ")
  66. response.write (Applicant)
  67. oRs.Close
  68. Set oRs = Nothing 
  69. End If
  70. %>
  71. </p>
  72. <p>
  73. Thank you,<br>
  74. Test User<br>
  75. College<br>
  76. Office of Admissions<br>
  77. <a href="mailto:user@college.edu?subject=Admissions">user@college.edu</a><br>
  78. <a href="http://www.college.edu/programs" target="_self">www.college.edu/programs</a></p>
  79. </font></body>
  80. </html>

try something like this pseudo code:
[code]response.write status

if status = ai
response.write all the null fields, use the loop or whatever
elseif status = ac
response.write all complete
else
response.write in review
end if [code]it sure looks like the problem is in the select case or if statement, not in the emailing, so try the above just to check if the if statement is executing at all.

Jared
Feb 22 '08 #10
jhardman
3,406 Expert 2GB
First- Please use the code tags available (the - # - button).

Second- Try this variation, let me know if it helps
Expand|Select|Wrap|Line Numbers
  1. '...
  2.         sMsg = sMsg & "Greetings " & FName & "!" & vbCRLF & vbCRLF
  3.         sMsg = sMsg & "Your application to the College has been received." & vbCRLF & vbCRLF
  4.  
  5.     IF ApplicationStatus = AI Then
  6.  
  7.         sMsg = sMsg & "Any missing items on your application are listed below:" & vbCRLF & vbCRLF
  8.         For Each oField In oRs.Fields
  9.         If IsNull( oRs( oField.name ) ) Then
  10.             sMsg = sMsg & oField.name & vbCRLF
  11.         End If
  12.         Next
  13.  
  14.     Else If ApplicationStatus = AC Then
  15.         sMsg = sMsg & "Your application is complete" & vbCRLF
  16.  
  17.     Else
  18.         sMsg = sMSG & "Under Review" & vbCRLF
  19.         End If
  20. '...
Feb 23 '08 #11
bpw22az
14
Jared,

For a second there I had it running. All three status codes were sending out the correct email, even the incomplete null fields, although I think I may have moved an 'End If' statement and now whenever the status = "AI" no email is sent. AC and UR still work. Latest below:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Applicant
  3. Set Applicant = Request.Form("txtEmailAddress")
  4. Dim oRs, oField, fieldCount, FName, Status
  5. Set oRs = Server.CreateObject("ADODB.Recordset")
  6. oRs.Open "vwAcademicsAdmissionsData WHERE Email = '" & Applicant & "';","DSN=OSC"
  7. Set FName = oRs("First_Name")
  8. Set Status = oRs("ApplicationStatus")
  9.  
  10. sMsg = sMsg & "Greetings " & FName & "!" & vbCRLF & vbCRLF
  11.         sMsg = sMsg & "Your application to the College has been received." & vbCRLF & vbCRLF
  12.  
  13.     IF Status = "AI" Then
  14.  
  15.         sMsg = sMsg & "Any missing items on your application are listed below:" & vbCRLF & vbCRLF
  16.         For Each oField In oRs.Fields
  17.         If IsNull( oRs( oField.name ) ) Then
  18.             sMsg = sMsg & oField.name & vbCRLF
  19.         End If
  20.         Next
  21.  
  22.     Else If Status = "AC" Then
  23.         sMsg = sMsg & "Your application is complete" & vbCRLF
  24.  
  25.     Else
  26.         sMsg = sMsg & "Under Review" & vbCRLF
  27.         End If
  28.  
  29. Dim Mail
  30. Set Mail = CreateObject("CDONTS.NewMail")
  31. Mail.From = "user@college.edu"
  32. Mail.To = Applicant
  33. Mail.Bcc = "helpdesk@college.edu"
  34. Mail.Subject = "Your Admission Status"
  35. Mail.Body = sMsg
  36. Mail.Send
  37. oRs.Close
  38. Set oRs = Nothing 
  39. End If
  40. %>
  41.  
Second- Try this variation, let me know if it helps
Expand|Select|Wrap|Line Numbers
  1. '...
  2.         sMsg = sMsg & "Greetings " & FName & "!" & vbCRLF & vbCRLF
  3.         sMsg = sMsg & "Your application to the College has been received." & vbCRLF & vbCRLF
  4.  
  5.     IF ApplicationStatus = AI Then
  6.  
  7.         sMsg = sMsg & "Any missing items on your application are listed below:" & vbCRLF & vbCRLF
  8.         For Each oField In oRs.Fields
  9.         If IsNull( oRs( oField.name ) ) Then
  10.             sMsg = sMsg & oField.name & vbCRLF
  11.         End If
  12.         Next
  13.  
  14.     Else If ApplicationStatus = AC Then
  15.         sMsg = sMsg & "Your application is complete" & vbCRLF
  16.  
  17.     Else
  18.         sMsg = sMSG & "Under Review" & vbCRLF
  19.         End If
  20. '...
Feb 25 '08 #12
jhardman
3,406 Expert 2GB
Subtle variation. "elseif" is one word.
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Applicant
  3. Set Applicant = Request.Form("txtEmailAddress")
  4. Dim oRs, oField, fieldCount, FName, Status
  5. Set oRs = Server.CreateObject("ADODB.Recordset")
  6. oRs.Open "vwAcademicsAdmissionsData WHERE Email = '" & Applicant & "';","DSN=OSC"
  7. Set FName = oRs("First_Name")
  8. Set Status = oRs("ApplicationStatus")
  9.  
  10. sMsg = sMsg & "Greetings " & FName & "!" & vbCRLF & vbCRLF
  11.      sMsg = sMsg & "Your application to the College has been received." & vbCRLF & vbCRLF
  12.  
  13. IF Status = "AI" Then
  14.  
  15.    sMsg = sMsg & "Any missing items on your application are listed below:" & vbCRLF & vbCRLF
  16.  
  17.    For Each oField In oRs.Fields
  18.  
  19.       If IsNull( oRs( oField.name ) ) Then
  20.          sMsg = sMsg & oField.name & vbCRLF
  21.       End If
  22.  
  23.    Next
  24.  
  25. ElseIf Status = "AC" Then
  26.  
  27.    sMsg = sMsg & "Your application is complete" & vbCRLF
  28.  
  29. Else
  30.  
  31.    sMsg = sMsg & "Under Review" & vbCRLF
  32.  
  33. End If
  34.  
  35. Dim Mail
  36. Set Mail = CreateObject("CDONTS.NewMail")
  37. Mail.From = "user@college.edu"
  38. Mail.To = Applicant
  39. Mail.Bcc = "helpdesk@college.edu"
  40. Mail.Subject = "Your Admission Status"
  41. Mail.Body = sMsg
  42. Mail.Send
  43. oRs.Close
  44. Set oRs = Nothing %>
  45.  
Feb 26 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: michaaal | last post by:
I realize this is not solely an ASP question, but I thought you guys might know the answer and I couldn't find anywhere else to post this. If you have suggestions for this I am more than happy to...
3
by: Michael Teja via SQLMonster.com | last post by:
Dear Mr Portas and Mr Sommarskog, Cause I am a newbie in sql, can I ask for your email address? My email Address is mike@ptmb.com Thanx Best Regards
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
13
by: joe215 | last post by:
I want my users to send emails from a Windows app that I am developing in Visual Basic.NET 2003. I found a good example of sending email to a SMTP server using the SmtpMail class. However, using...
2
by: RAB | last post by:
I have a .aspx page with the following code: <% @Import Namespace="System.Web.Mail" %> <%@ page language="vb" debug="true" runat="server" %> <script runat="server"> Sub Click(sender as...
3
by: zek2005 | last post by:
Hi folks! I need help with the following. I made a form so the user can make a question and that question has to be inserted in my database, but before the question (and other information of the...
12
by: ll | last post by:
I am trying to finalize a regular expression in javascript to only allow emails with a certain domain to be valid. Here is what I have so far: var emailFilter2=/\@aol.com/;...
3
by: JJ297 | last post by:
Hello, After a user enters their request I'm sending a generated email to someone. How do I get that question to appear in the email? I have the link appearing in the email. This is what I...
5
by: canajien | last post by:
I have a form that stores information in a table, but I also need it to send an email when a specific question, among the many, is answered with no the question is a simple drop box: <select...
6
by: gnewsgroup | last post by:
I am using Peter Bromberg's code to send email through gmail smtp service in my asp.net web application. Thanks, Peter. The problem with gmail smtp is that gmail will overwrite the sender's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.