-
ASP & cdo nts
I'm trying to send an email from my asp page.
Using Interdev / iis 4 / VB
The code i'm using is as follows
********************************
Sub Button3_onclick()
Set objSendMail = CreateObject("CDONTS.NewMail")
With objSendMail
.From = "[email protected]"
.To = "[email protected]"
.Subject = "Testing ASP cdonts"
.Body = "This is a test of sending email from ASP."
.Send
End with
Set objSendMail = Nothing
End Sub
**********************8
I have referenced the CDO for NTS 1.2 library in the project.
No errors are generated , its just nothing is happening , no emails , nothing.
Any ideas let me know?
;) ;) :confused:
-
Make sure the Button3_onclick() sub gets called (on the server side, not by clicking buttons on the client side).
-
i'm a newbie to asp ,
can you explain how to call the sub from the server side.
-
There aren't events in ASP like there are in VB. (There's a handful bases on server events). ASP processes code from the top of your code to the bottom. So to call a sub, just have it in the <%
Ex:
Code:
<%
Option Explicit
Response.Write "<html><body>" & vbcrlf
'write a word three times
WriteThreeTimes("Word")
Response.Write "</body></html>" & vbcrlf
Sub WriteThreeTimes(word)
Response.Write word & vbcrlf word & vbcrlf word & vbcrlf
End Sub
%>
-
what i'm doing now is as follows
sub button_click()
Page2.navigateURL("mail.asp")
end sub
---then the code for mail.asp is
<%@language=vbscript%>
<%
Set objSendMail = server.CreateObject("CDONTS.NewMail")
With objSendMail
.From = "[email protected]"
.To = "[email protected]"
.Subject = "Testing ASP cdonts"
.Body = "This is a test of sending email from ASP."
.Send
End with
Set objSendMail = Nothing
response.write "Your email has been sent."
%>
*****************************88
in theory this should work , as the mail routine is being called from the server side.
Unfortunately for me it still aint doing anything.
any ideas??
:confused: :confused:
-
That looks okay to me. You not getting any errors, right? Are you just not getting the mail? Check the configuration of the SMTP service on your server, then make sure it can relay the mail.