asp formmail auto responder

114 Views Asked by At

I'm very bad at coding

i have a asp formmail for subscribe email. I do get emails but I want to send a autoresponse saying "Thank you for subscription". Also the same for my contact page formmail.

Below is my current code can you tell me how do I go about the same.

 <%

dim sEmailContent


sEmailContent = sEmailContent & "Subscribe : " & Request.Form("subscribe") & vbCrLf

Response.Write(sEmailContent)

'call send_email("[email protected]",sEmailContent)
call send_email("[email protected]",sEmailContent)

function send_email(sToEmail,sEmailBody)
on error resume next
    Dim ObjSendMail
    Set ObjSendMail = CreateObject("CDO.Message")

    'Configuration for remote SMTP server

    'Network Send    
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    'Name of SMTP server
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="relay-hosting.secureserver.net"

    'SMTP port
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

    'MaxESP SMTP servers require authentication

    'Basic Authentication
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

    'SMTP username as configured in the control panel
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]"

    'SMTP user password as configured in the control panel
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="blabla"

    ObjSendMail.Configuration.Fields.Update


    'Configuration for email message

    'Email To address
    'ObjSendMail.To = "[email protected]"
    'ObjSendMail.To = "[email protected]"
    ObjSendMail.To = sToEmail
    'Email Subject
    ObjSendMail.Subject = "Newsletter Subscription"

    'Email From address
    ObjSendMail.From = "[email protected]"

    'Email Body
    ObjSendMail.TextBody = sEmailBody

    ObjSendMail.Send

    Set ObjSendMail = Nothing

    response.Redirect("thank-you.html")
if err.number <> 0 then
    Response.Write(err.Description)
end if
on error goto 0 
end function
 %> 
1

There are 1 best solutions below

0
On BEST ANSWER

move your function function send_email(sToEmail,sEmailBody) into separate file, let's say into "Emails.asp".

in contact page and in subscribe asp pages add following line to include your "Email.asp"

<!-- #include file="Emails.asp" -->

then call send_email as before