converting send mail PHP to ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jason3107
    New Member
    • Mar 2008
    • 1

    #1

    converting send mail PHP to ASP

    I have the following code that i wish to know how is done in ASP.

    can someone please advise the best method to do the same as in my php script.

    thank you in advance for your help

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <?
    $from_private_sys_email="noreply@noreply.com";
    $email_headers = "Content-Type: text/html; charset=ISO-8859-1\r\nFrom: ".$from_private_sys_email."\r\n";
    if ($_POST['Submit'] <> "Submit") {
    mail("test@test.com","subject","message","$emailheaders");
    } else {
    ?>
    <form action="" method="post"><input name="name" type="text"><input name="Submit" type="submit" value="Submit"></form>
    <?
    }
    ?>
    </body>
    </html>
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Jason,

    You can use the script below to send mail from an ASP page - is that what you wanted?

    You'll need to configure it with the IP address of your smtp server (or leave it as 127.0.0.1 if you are using your local IIS smtp) and set the variables sSubject, sFrom, sTo, sBody & sAttachment as required.

    Code:
    Const cdoSendUsingPort = 2 
    set iConf = CreateObject("CDO.Configuration")
    Set Flds = iConf.Fields
     
    ' Set the CDOSYS configuration fields to use port 25 on the SMTP server.
    With Flds
    .Item("[url="http://schemas.microsoft.com/cdo/configuration/sendusing"]http://schemas.microsoft.com/cdo/configuration/sendusing[/url]") = cdoSendUsingPort
    .Item("[url="http://schemas.microsoft.com/cdo/configuration/smtpserver"]http://schemas.microsoft.com/cdo/configuration/smtpserver[/url]") = "127.0.0.1"
    .Item("[url="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout[/url]") = 30
    .Update
    End With
     
    Set myMail=CreateObject("CDO.Message")
    Set myMail.Configuration = iConf
    myMail.Subject = sSubject
    myMail.From = sFrom
    myMail.To = sTo
    myMail.TextBody = sBody
    myMail.AddAttachment sAttachment
    myMail.Send
     
    set myMail=nothing
    Set iConf = Nothing
    Set Flds = Nothing
    Does this help?

    Dr B

    Comment

    Working...