PDA

Click to See Complete Forum and Search --> : ASP Subs/functions - please


turfbult
May 28th, 2001, 03:42 AM
Hello,

How do you declare a function/sub in ASP (NOT VBScript....).
I want to do something like

onclick="email()"
< script language="VBScript">
sub email
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
mailer.fromname = "TEST"
mailer.fromaddress = "myemail.com"
Mailer.RemoteHost = "myremotehost.net"
mailer.addrecipient "Test","YourAddress.com"
mailer.subject = "Testing"
mailer.bodytext = "Hello"
end sub


I get errors like "Server not an object" and "mailer not an object".

Thanks,
T

kovan
May 28th, 2001, 04:00 AM
onclick="email()"
< script language="VBScript">
Sub Emailer()
set mailer = Server.CreateObject("SMTPsvg.Mailer")
mailer.fromname = "TEST"
mailer.fromaddress = "myemail.com"
mailer.RemoteHost = "myremotehost.net"
mailer.addrecipient "Test","YourAddress.com"
mailer.subject = "Testing"
mailer.bodytext = "Hello"
end sub

make sure you have the smtpsvg dlls on the server ect..

turfbult
May 28th, 2001, 04:08 AM
Thanks kovan,

Why do I get the error "mailer not an object" (or something like that). Is the code in VBScript the same as ASP?? (Most probably a stupid question...??!!)

How do I do a response.write within this function. I got an error when trying to do a response.write.

I'm just used to writting all my code withing the <% %> tags - never used "< script language="VBScript"> "

thanks,
T

kovan
May 28th, 2001, 04:15 AM
using <% %> is same thing as writing script.....

as far as i know
i never use the script tag
just <%

use <% instead
and use response.write...

why are you getting an error?
i dont know what type of emailer your making
but it seems that it cant create the object

try the generic emailer object..

Jeh
May 28th, 2001, 09:09 AM
looks like you are trying to set the object on the actual page itself so when something is clicked it sends the email, as far as I know, you cant do that
the code to send the email needs to be in between <% %> tags and not on the same page as the thing thats clicked
best way would be use a form then when the form is submitted send the email and then show some html saying well done its been sent etc.

turfbult
May 28th, 2001, 12:57 PM