Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Mlucas1
Starting Member
5 Posts |
Posted - 2006-08-10 : 15:47:50
|
OK I am pretty new to this stuff. I hired programmers who left me in the lurch so I am trying to figure things out on my own I am having some real problems with the mailer scripts I have inserted some code I got one script working but having probs with this one. Any help appreciated!Also to note is "EMail an alias from User table because there is only an "email" column not EMail...<%cn = Session("cnn")Set rs = Server.CreateObject("ADODB.Recordset")rs.ActiveConnection = cnIf Request.Form("btOk.x") > "0" thensFEmail = Request.Form("EMail")FromName = Request.Form("sYName") sYEmail = Request.Form("sYEmail") sIdTalent= Request.Form("sIdTalent") Message = Request.Form("sMessage")If Len(sFEmail) > 3 and InStr(1, sFEmail, "@") > 1 thenIf Len(sYEmail) > 3 and InStr(1, sYEmail, "@") > 1 thensQuery = "Select EMail From Table Where UserId = " &sIdTalent rs.Source = sQueryrs.OpenIf not rs.EOF then ' THIS SENDS AN EMAIL TO SOMEONE TELLING THEM ABOUT THE NEW REGISTRATIONREM Message bodyTextHeader = "This message is For :" & Chr(13) & Chr(10)TextEnd = Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Thank You"FromName = "sYName" & Chr(13) & Chr(10)Message = "sMessage" & VbCrLf & "http://" & Chr(13) & Chr(10) & Comments & Chr(13) & Chr(10)Dim MailerDim sMessageDim FromNameDim sFEmailDim sYEmailSet Mailer = Server.CreateObject("SMTPsvg.Mailer")Mailer.RemoteHost = "smtp.server.cot"Mailer.FromName = "FromName"Mailer.FromAddress = sYEmailMailer.AddRecipient sFEmail, Request.Form("email")Mailer.BodyText = TextHeader & vbCrLf & Chr(13) & Chr(10) & Message & TextEndMailer.Subject = "anything"Mailer.SendMail if Mailer.SendMail thenResponse.Write "Ok ! Your message send to !..."elseResponse.Write "Mail send failure. Error was " & Mailer.Responseend if%><h3><font color="green">Ok ! Your Message is sent to <%=FirstName%> (of Talent would be nice!!!!)!</font></h3><% else %><font color=""red"">Error send message ! EMail address not valid !</font><%End ifrs.CloseElseIf Request.QueryString("Id") > "0" thensIdTalent = Request.QueryString("Id")ElseIf Session("iUserId") > 0 thensUserId = CStr(Session("iUserId"))End IfsQuery = "Select * From Table Where UserId = " &sUserIdrs.Source = sQueryrs.OpenIf rs.EOF thensYName = ""sYEmail = ""ElsesYName = rs.Fields("FirstName").value&" "&rs.Fields("MiddleName").value&" "&rs.Fields("LastName").valuesYEmail = rs.Fields("email").valuesFEmail = rs.fields("EMail").ValueEnd Ifrs.CloseEnd IfEnd IfEnd IfEnd If%> |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-08-10 : 16:51:55
|
If you tell us specifically what the problem is (error messages? emails not sent? going to wrong place? etc) I bet we will be able to help you, or if you ask a specific question.- Jeff |
 |
|
Mlucas1
Starting Member
5 Posts |
Posted - 2006-08-11 : 09:52:10
|
Ok I am not getting any errors. When i press submit it just basically reloadsBut I am also not getting aqn email either. And none of the sent or not sent messages are showing up.Like I said I didn't write the whole script so A. I am not sure if it sends an email using the users address or if Fromadress should be the host email address with users email address attached.I am still working on it Thanks |
 |
|
KenW
Constraint Violating Yak Guru
391 Posts |
Posted - 2006-08-11 : 14:42:12
|
quote: Originally posted by Mlucas1 OK I am pretty new to this stuff. I hired programmers who left me in the lurch so I am trying to figure things out on my own I am having some real problems with the mailer scripts I have inserted some code I got one script working but having probs with this one. Any help appreciated!
Gee... Where to begin? :-)First, when posting here, mark your code as code (see the little button on the toolbar marked with '#'). It makes it much easier to read, because it will retain the formatting.Ok...<%cn = Session("cnn")Set rs = Server.CreateObject("ADODB.Recordset")rs.ActiveConnection = cnIf Request.Form("btOk.x") > "0" then sFEmail = Request.Form("EMail") FromName = Request.Form("sYName") sYEmail = Request.Form("sYEmail") sIdTalent= Request.Form("sIdTalent") Message = Request.Form("sMessage") If Len(sFEmail) > 3 and InStr(1, sFEmail, "@") > 1 then If Len(sYEmail) > 3 and InStr(1, sYEmail, "@") > 1 then sQuery = "Select EMail From Table Where UserId = " &sIdTalent rs.Source = sQuery rs.Open If not rs.EOF then ' THIS SENDS AN EMAIL TO SOMEONE TELLING THEM ABOUT THE NEW ' REGISTRATION 'REM Message body To this point, the only issue seems to be the line starting with REM. AFAIK, VBScript doesn't use that as a comment, so your code should blow up there. TextHeader = "This message is For :" & Chr(13) & Chr(10) I presume that you don't know that 'vbCRLF' is the same thing as 'Chr(13) & Chr(10)', except 'vbCRLF' is a lot shorter to type and easier to read. :-)So the lines should have every instance of 'Chr(13) & Chr(10)' replaced with 'vbCRLF'. FromName = "sYName" & Chr(13) & Chr(10) Message = "sMessage" & VbCrLf & "http://" & Chr(13) & Chr(10) & Comments & Chr(13) & Chr(10) I don't think you're accomplishing what you want here. By putting the "sYName" and "sMessage" in quotes, you're using them literally instead of using the values they contain (which you've read from Request.Form() above).Instead, use 'FromName = sYName & vbCRLF'; do the same thing with Message.Dim MailerDim sMessageDim FromNameDim sFEmailDim sYEmail Another problem. Since you've already DIM'd FromName above, you can't DIM it again here without replacing the value you just finished assigning to it. I'd suggest you move all of your DIM statements up to the top of your code (right below the '<%' that starts it), and remove all duplicates.Set Mailer = Server.CreateObject("SMTPsvg.Mailer")Mailer.RemoteHost = "smtp.server.cot"Mailer.FromName = "FromName" You have the same problem with double quotes around "FromName" as you did with the "sYName" above. Remove the quotes.Mailer.AddRecipient sFEmail, Request.Form("email") I'm not sure what you're doing here. You're adding Request.Form("email") as a recipient twice - once from the sFEMail variable, and a second time by getting it from Request.Form("email").Mailer.BodyText = TextHeader & vbCrLf & Chr(13) & Chr(10) & Message & TextEndMailer.Subject = "anything" Same here with the vbCRLF/Chr(13) & Chr(10).The rest of the code doesn't look too bad, although you might be missing a couple of EndIf statements; I can't tell with the formatting the way it is.Ken |
 |
|
KenW
Constraint Violating Yak Guru
391 Posts |
Posted - 2006-08-11 : 14:43:04
|
Jeff,quote: Originally posted by jsmith8858 If you tell us specifically what the problem is (error messages? emails not sent? going to wrong place? etc) I bet we will be able to help you, or if you ask a specific question.- Jeff
Didn't look too hard, did you? |
 |
|
Mlucas1
Starting Member
5 Posts |
Posted - 2006-08-11 : 18:36:28
|
I cleared up the code some.I am a litle confused about how I am getting the EMAIL address of of the person we are sending to.sIdTalent - is a seperate table that does not hold the rs.email the ID is linked to another table that holds the email address.as a matter of fact this script calls on both the User ID Email and Sendee ID email which are both located in the User TableHenceSelect EMail From User Where UserId = " &sIdTalent So the sldTalent (Dif table) should look up the email address which is located in the User Table that corresponds with the Talent data.<%Dim MailerDim sNameDim sMessageDim sFEmailDim sYEmailcn = Session("cnn")Set rs = Server.CreateObject("ADODB.Recordset")rs.ActiveConnection = cnIf Request.Form("btOk.x") > "0" thensFEmail = Request.Form("EMail")sName = Request.Form("sYName") sYEmail = Request.Form("sYEmail") sIdTalent= Request.Form("sIdTalent") Message = Request.Form("sMessage")If Len(sEmail) > 3 and InStr(1, sEmail, "@") > 1 thenIf Len(sYEmail) > 3 and InStr(1, sYEmail, "@") > 1 thensQuery = "Select EMail From User Where UserId = " &sIdTalent rs.Source = sQueryrs.OpenIf not rs.EOF then sFEmail = rs.Fields("EMail").Value' THIS SENDS AN EMAIL TO Talent Message body TextHeader = "This message is For :" & Chr(13) & Chr(10) TextEnd = Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Thank You" msgComments = Message & Chr(13) & Chr(10) & "http://www." & Chr(13) & Chr(10) Set Mailer = Server.CreateObject("SMTPsvg.Mailer") Mailer.RemoteHost = "smtp.server.net" Mailer.FromName = sName Mailer.FromAddress = sYEMail Mailer.AddRecipient sEmail Mailer.BodyText = TextHeader & vbCrLf & Chr(13) & Chr(10) & msgComments & TextEnd Mailer.Subject = "Hello Talent"Mailer.SendMail if Mailer.SendMail thenResponse.Write "<h3><font color="green">Ok ! Your Message is sent to !</font></h3>"elseResponse.Write "<font color=""red"">Error send message ! EMail address not valid !</font> " & Mailer.Responseend ifrs.CloseElseIf Request.QueryString("Id") > "0" thensIdTalent = Request.QueryString("Id")ElseIf Session("iUserId") > 0 thensUserId = CStr(Session("iUserId"))End IfsQuery = "Select * From Table Where UserId = " &sUserIdrs.Source = sQueryrs.OpenIf rs.EOF thensYName = ""sYEmail = ""ElsesYName = rs.Fields("FirstName").value&" "&rs.Fields("MiddleName").value&" "&rs.Fields("LastName").valuesYEmail = rs.Fields("email").valuesFEmail = rs.Fields("EMail").Valuers.Close' need all these end ifs to stop errorEnd IfEnd IfEnd IfEnd IfEnd If%> |
 |
|
Mlucas1
Starting Member
5 Posts |
Posted - 2006-08-21 : 14:06:33
|
somehow I got it working thanks |
 |
|
|
|
|
|
|