Results 1 to 6 of 6

Thread: ASP Script

  1. #1
    Join Date
    Nov 2005
    Location
    Utica, NY
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ASP Script

    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 =)

  2. #2
    Join Date
    Oct 2006
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    im a bit late in replying, but i don't understand what you're asking for

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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:
    PHP Code:
    <?php
    mail
    (to,subject,body,extraheaders...)

    //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:
    mail($to,$subject,$body,$headers);
    //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...
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    at the end of this line there is an un-needed single quote

    PHP Code:
    $body $_POST['body']."\nUser's IP: ".$_SERVER['REMOTE_ADDR']'; 
    that's why the board isn't parsing the comments below it.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Nov 2006
    Location
    UK
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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...

  6. #6
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    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

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body><b>
    Please note that this page lacks the form field validation.
    <br>
    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>
    </b>
    <form name="f1" action="sendMail.asp" method="post">
    From &nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="from">
    <br>
    To &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="to"><br>
    Subject
    <input type="text" name="subject"><br>
    <br>
    Message
    <textarea name="message" cols="30" rows="10"></textarea>
    <br>
    <input type="submit" name="submit" value="click">
    </form>
    </body>
    </html>
    Back end ASP file using which you are sending the mail in other words back end file of the above mentioned html page.

    Code:
    <%
    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 
    .Fields.Update 
     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
      myMail.To=toarr(i)
      myMail.Send
    Next
    
    Set myMail=nothing   
    %>
    Please provide your SMTP server name within the ASP code.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •