943,822 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Marked Solved
  • Views: 3427
  • ASP RSS
Jun 24th, 2009
0

Sending an Automatic Email

Expand Post »
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

ASP Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 11
Solved Threads: 0
Light Poster
whisper_101 is offline Offline
25 posts
since May 2008
Jun 25th, 2009
0

Re: Sending an Automatic Email

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
Reputation Points: 10
Solved Threads: 5
Newbie Poster
chsab420 is offline Offline
23 posts
since Jun 2009
Jun 25th, 2009
0

Re: Sending an Automatic Email

Thankyou - works well.
Reputation Points: 11
Solved Threads: 0
Light Poster
whisper_101 is offline Offline
25 posts
since May 2008
Dec 14th, 2009
0
Re: Sending an Automatic Email
Hey ive tried this code and several others too and it doesnt seem to work...
Is there nething else besides the code which i need to do to get it to work?
Appreciate the help...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mystick is offline Offline
1 posts
since Dec 2009
Dec 17th, 2009
0
Re: Sending an Automatic Email
am selling business handout online not too cost
Reputation Points: 10
Solved Threads: 0
Newbie Poster
oluwa4real37 is offline Offline
1 posts
since Dec 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: asp with access 2000
Next Thread in ASP Forum Timeline: GridView Data Fetch





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC