PDA

View Full Version : SMTP problems


John316
09-19-02, 03:23
Hi all,

I have created a web ordering form. My question is I am trying to create 2 buttons. On my admin side.

Button One) – If the admin clicks this button it will shot off an email to another admin for shipping.

Button Two) – If the admin rejects the order this button will need to send an email to a different admin.

So how do I send email to two different email address on the same form?


Thanks,
John316

JonathanB
09-19-02, 07:25
In the past I've used JavaScript to perform that task... although you can acheive your aim by just turning the two buttons into normal links providing you don't need to send any form data to the e-mail script.

Mulligan
09-19-02, 09:44
Make both the buttons submit buttons, name one "accept" and one "reject". When you POST the form, you can do something like:

If Request.Form("accept").Count <> 0 Then
' Send acceptance email to admin for shipping
ElseIf Request.Form("reject").Count <> 0 Then
' Send the other email
Else
' Throw an error
End If
Use CDO (Collaboration Data Objects) to create and send the emails.

Mull.

John316
09-19-02, 11:42
How do I add your code to my CDO? My CDO is listed below:

<%
' Else
' Response.Write "Cannot page out! Code: " & mailer.ErrorString
' End If
Set mailer=Nothing
%>
<%
Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
%>
<%

' First create an instance of NewMail Object
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = Request.Form("User_email")
objNewMail.To = "test.admin@sample.com"

objNewMail.Subject = "Order Request. <automated message>"
objNewMail.Body = "This is just a test."

objNewMail.Send
Set objNewMail = Nothing

%>

Thanks,
John316

Originally posted by Mulligan
Make both the buttons submit buttons, name one "accept" and one "reject". When you POST the form, you can do something like:

If Request.Form("accept").Count <> 0 Then
' Send acceptance email to admin for shipping
ElseIf Request.Form("reject").Count <> 0 Then
' Send the other email
Else
' Throw an error
End If
Use CDO (Collaboration Data Objects) to create and send the emails.

Mull.

Mulligan
09-19-02, 11:49
Try something like this. Cut down for size. The form submits to itself (well, its own page) and the top of the page checks for which button has been pressed. Based on that, we send to one email address or the other.

<%

Dim accepting
Dim rejecting

accepting = Request.Form("accept").Count <> 0
rejecting = Request.Form("reject").Count <> 0

If accepting Then

Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")

' First create an instance of NewMail Object
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = Request.Form("User_email")
objNewMail.To = "test.admin@sample.com"

objNewMail.Subject = "Order Request. <automated message>"
objNewMail.Body = "This is just a test."

objNewMail.Send
Set objNewMail = Nothing

ElseIf rejecting Then

' CDO to rejected email address

End If
%>
<form name="mailer" action="thispage.asp" method="post">
<input type="submit" name="accept" value="Accept" />
<input type="submit" name="reject" value="Reject" />
</form>

John316
09-19-02, 13:54
I tried you code and it did not send an email. Is there something else I could try?

John316

Originally posted by Mulligan
Try something like this. Cut down for size. The form submits to itself (well, its own page) and the top of the page checks for which button has been pressed. Based on that, we send to one email address or the other.

<%

Dim accepting
Dim rejecting

accepting = Request.Form("accept").Count <> 0
rejecting = Request.Form("reject").Count <> 0

If accepting Then

Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")

' First create an instance of NewMail Object
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = Request.Form("User_email")
objNewMail.To = "test.admin@sample.com"

objNewMail.Subject = "Order Request. <automated message>"
objNewMail.Body = "This is just a test."

objNewMail.Send
Set objNewMail = Nothing

ElseIf rejecting Then

' CDO to rejected email address

End If
%>
<form name="mailer" action="thispage.asp" method="post">
<input type="submit" name="accept" value="Accept" />
<input type="submit" name="reject" value="Reject" />
</form>

John316
09-19-02, 14:06
And since I need to have the .asp form email to different address it will not work your way. That will only email one email address not 2.

John316