Sending an Automatic Email

Please support our ASP advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: May 2008
Posts: 25
Reputation: whisper_101 is an unknown quantity at this point 
Solved Threads: 0
whisper_101 whisper_101 is offline Offline
Light Poster

Sending an Automatic Email

 
0
  #1
Jun 24th, 2009
Hi Guys

I have been working on an Automatic Email Function. The code returns two different email addresses which are used to send emails to. The problem is - in second email sent the Body of the text is repeated twice i.e.

In the First Email Sent:

Welcome to the Jobs by Email Service

Wigs

But in the Second Email Sent:

Welcome to the Jobs by Email Service

Wigs

Welcome to the Jobs by Email Service

Wigs

  1. <!--Connection To Database -->
  2. <!-- #INCLUDE FILE="Openconnection-for-local-use.asp" -->
  3.  
  4. <!--Email Alert -->
  5.  
  6. <%
  7.  
  8. Dim rsEmailAlert_numRows
  9.  
  10. strSQL = "SELECT Table_Salon_Info.S_Skills_Required, Table_Salon_Info.S_Skills_Location, Table_Email_Alert.A_Email FROM Table_Salon_Info INNER JOIN Table_Email_Alert ON Table_Salon_Info.S_Skills_Required = Table_Email_Alert.A_Stylist_Type WHERE (Table_Salon_Info.S_Id = 1) AND (Table_Salon_Info.S_Skills_Location = 'London')"
  11.  
  12. Set rsEmailAlert = Server.CreateObject("ADODB.Recordset")
  13.  
  14. rsEmailAlert.open strSQL,Conn
  15.  
  16. rsEmailAlert_numRows = 0
  17. %>
  18.  
  19. <!--LOOP AROUND THE ARRAY TO RETRIEVE ALL VALUES -->
  20.  
  21. <%
  22. Dim Repeat1__numRows
  23. Repeat1__numRows = -1
  24. Dim Repeat1__index
  25. Repeat1__index = 0
  26. rsEmailAlert_numRows = rsEmailAlert_numRows + Repeat1__numRows
  27. %>
  28.  
  29. <%
  30. <!--SEND EMAILS TO STYLIST MATCHES-->
  31. While ((Repeat1__numRows <> 0) AND (NOT rsEmailAlert.EOF))
  32. %>
  33.  
  34.  
  35. <%
  36. Dim ObjSendMail
  37. Set ObjSendMail = CreateObject("CDO.Message")
  38.  
  39. <!--This section provides the configuration information for the remote SMTP server. -->
  40.  
  41. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration
  42. /sendusing") = 2 <!--Send the message using the network -->(SMTP over the network).
  43. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration
  44. /smtpserver") ="mail.blackhair-salons.com"
  45. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration
  46. /smtpserverport") = 25
  47. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration
  48. /smtpusessl") = False <!--Use SSL for the connection (True or False) -->
  49. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration
  50. /smtpconnectiontimeout") = 60
  51. <!--If your server requires outgoing authentication uncomment the lines below and use a valid email address and password. -->
  52. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration
  53. /smtpauthenticate") = 1 <!--basic (clear-text) authentication -->
  54. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration
  55. /sendusername") ="info@hair-salons.com"
  56. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration
  57. /sendpassword") ="insonline"
  58.  
  59. ObjSendMail.Configuration.Fields.Update
  60.  
  61. <!--End remote SMTP server configuration section== -->
  62.  
  63. ObjSendMail.To = (rsEmailAlert.Fields.Item("A_Email").value)
  64. ObjSendMail.Subject = "New Jobs Matching -" &" " & (rsEmailAlert.Fields.Item("S_Skills_Required").value) &"," &" " & (rsEmailAlert.Fields.Item("S_Skills_Location").value)
  65. ObjSendMail.From = "info@hair-salons.com"
  66.  
  67. Dim strBody
  68.  
  69. strBody = strBody & "Welcome to the Jobs by Email Service" & vbCrLf & vbCrLf
  70. strBody = strBody & (rsEmailAlert.Fields.Item("S_Skills_Required").value) & vbCrLf ObjSendMail.TextBody = strBody
  71. ObjSendMail.Send
  72.  
  73. Set ObjSendMail = Nothing
  74. %>
  75.  
  76.  
  77. <%
  78. Repeat1__index=Repeat1__index+1
  79. Repeat1__numRows=Repeat1__numRows-1
  80. rsEmailAlert.MoveNext()
  81. Wend
  82. %>
  83. <%
  84. Response.Write "Email Alerts Sent"
  85. %>
  86.  
  87. <%
  88. rsEmailAlert.Close()
  89. %>

Any help would be great - Thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 23
Reputation: chsab420 is an unknown quantity at this point 
Solved Threads: 5
chsab420 chsab420 is offline Offline
Newbie Poster

Re: Sending an Automatic Email

 
0
  #2
Jun 25th, 2009
write this
strBody = "" before completing a loop
it will clear already whatever is in this so it will not repeat
try it and it will work
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 25
Reputation: whisper_101 is an unknown quantity at this point 
Solved Threads: 0
whisper_101 whisper_101 is offline Offline
Light Poster

Re: Sending an Automatic Email

 
0
  #3
Jun 25th, 2009
Thankyou - works well.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC