View Full Version : ASP Script

10-16-2006, 06:24 PM
Can anyone hook me up with an .asp script that will email form attributes to users i identify. then if i wanted to i could use the same script and customize it for who it goes to, and what its for.

please let me know, help is good =)

10-22-2006, 01:48 AM
im a bit late in replying, but i don't understand what you're asking for

10-22-2006, 02:53 AM
No clue about ASP. I assume it's possible.
Google it as it's a pretty basic function. At least in PHP, it is.
In PHP, it's quite easy:

//That's it.

//And use POST vars from the form:

$to = $_POST['to'];
//assuming there was a field named "to" in the form.

$body = $_POST['body']."\nUser's IP: ".$_SERVER['REMOTE_ADDR']';
//simple example of using the body field plus new line plus IP in an email.
//lots more could be done.

//rewrite the function above like:
//so it can use the variables above.
//you could also use strings directly, etc.

///additional headers are like from, reply-to, formatting, etc etc.
So... you could just do it in PHP, if that works, or this might help you with ASP, at least in the overall theory of things.

Good luck.

EDIT: not sure why the board isn't parsing the comments correctly...

10-25-2006, 09:16 PM
at the end of this line there is an un-needed single quote

$body = $_POST['body']."\nUser's IP: ".$_SERVER['REMOTE_ADDR']';

that's why the board isn't parsing the comments below it.

11-10-2006, 09:02 AM
ASP doesn't have an integrated mail handler, you will need to look around for a server add on which you would have to call using the Server.CreateObject() function, this would be the best way of going about it, I'm sorry I can't provide a link to a module for you... will try to find one later...

11-17-2006, 07:31 AM
First of all the code I am going to provide is just the skelton of what you had mentioned in your posting.

Based on the following code I think you can build your code. The code lacks form validation and SMTP authentication,etc

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
Please note that this page lacks the form field validation.
If you want please provide the necessary client-side or server side form field validation<br>

In the To field enter the person's email addresses seperated by comma.

<br>I am assuming that everything goes well in this example<br>
<form name="f1" action="sendMail.asp" method="post">
From &nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="from">
To &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="to"><br>
<input type="text" name="subject"><br>
<textarea name="message" cols="30" rows="10"></textarea>
<input type="submit" name="submit" value="click">

Back end ASP file using which you are sending the mail in other words back end file of the above mentioned html page.

Dim from,to,sub,message,toarr

from = Request.Form("from")
to = Request.Form("to")
sub = Request.Form("sub")
mesg = Request.Form("message")

if from = "" OR to = "" OR mesg ="" then
Response.redirect "error.html" 'error.html will display some kind of error message
end if

toarr = split(to,",") 'Now toarr contains all the to email addresses that were seperated by commas in it.
Dim toCount,i
toCount = UBound(toarr);

toCount = toCount - 1

Set myMail=CreateObject("CDO.Message")
Set objConn = Server.CreateObject ("CDO.Configuration")

Dim strSchemas
strSchemas = "http://schemas.microsoft.com/cdo/configuration/"
With objConn
.Fields(strSchemas & "smtpserver") = "mail.yoursmtpserver.com" 'Please specify your SMTP server information here
Fields(strSchemas & "smtpserverport") = 25
.Fields(strSchemas & "sendusing") = 2
.Fields(strSchemas & "smtpconnectiontimeout") = 60
End With

Set mymail.Configuration = objConn
myMail.MimeFormatted = true

myMail.From = from
myMail.Subject = sub

'HTML mail uncomment it if you need the following line and comment the text mail content line
myMail.HTMLBody = "<HTML><BODY><font face=verdana><table width=80% align=center><tr><td width=35% align=right><b>"& mesg &"</b></td></tr></table></font></BODY></HTML>"

'Text mail content
myMail.TextBody = mesg

For i = 0 To toCount

Set myMail=nothing

Please provide your SMTP server name within the ASP code.