Forums

This topic is locked

jmail after inserting record

Posted 04 Sep 2002 08:25:27
1
has voted
04 Sep 2002 08:25:27 Dave Clarke posted:
ok guys, i've had this problem before and resolved it but I can't remember what i did.
If i post the form directly to this page

<b>
&lt;%

firstname = request.querystring("newfirstname"
lastname = request.querystring("newlastname"
emailadd = request.querystring("newemailaddress"
username = request.querystring("newusername"
password = request.querystring("newpassword"

if emailadd ="" or instr(emailadd,"@"=0 then response.redirect("welcomenewmemb2.asp"


crlf=chr(13)+chr(10)
tab=chr(9)
tab2=chr(9)+chr(9)
tab3=chr(9)+chr(9)+chr(9)
tab4=chr(9)+chr(9)+chr(9)+chr(9)

Set JMail = Server.CreateObject("JMail.SMTPMail"
JMail.ClearRecipients
JMail.body = ""
JMail.ServerAddress = "serveraddress"
JMail.Sender = " "
JMail.Subject = "Your Membership Details"
JMail.AddRecipient emailadd
JMail.Body = "Hello" & tab2 & firstname & tab2 & lastname & "Welcome To www.reunite.co.uk"+crlf+crlf

JMail.appendtext "Here are your membership details" & crlf & crlf
JMail.appendtext "Username" & tab2 & username & crlf
JMail.appendtext "Password" & tab2 & password & crlf




JMail.Priority = 1
JMail.Execute
response.redirect("welcomenewmemb.asp"
%&gt;
</b>

it works fine and the jmail gets sent, but if i use an insert behaviour on the page and use the "After inserting go to" to go to the above page, the mail doesnt get sent, the record is inserted but no mail is sent, in fact the line that redirects if no email address is present
<b>if emailadd ="" or instr(emailadd,"@"=0 then response.redirect("welcomenewmemb2.asp"
</b>
comes into play, even if there is an email address.
If i remove that line (and make sure i enter an email address) then it doesnt redirect but the mail still doesnt get sent, it comes up with an "All servers did not recieve the email" error.
It must be something simple cos i've resolved it before but like i say i cant remember how
help please

Dave

Replies

Replied 04 Sep 2002 20:50:32
04 Sep 2002 20:50:32 Dave Clarke replied:
Ok, i think this is a problem similar to the one that everybody has about retreiving a record ID after an insert, in that the standard MM insert behaviour puts Request.QueryString in for POSTED forms instead of Request.Form.
So I have gone in and changed the following instances of Request.QueryString to Request.Form and it seems to be working, it's inserting the record and sending the mail.
I would appreciate comments.

Dave

<b>' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL")
If (Request.QueryString &lt;&gt; "" Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If</b>

and

<b>' append the query string to the redirect URL
If (MM_editRedirectUrl &lt;&gt; "" And Request.QueryString &lt;&gt; "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString &lt;&gt; "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
</b>


Reply to this topic