It is not that hard to create a mail form in asp. In many cases we might
need to create forms like feedback or contact form and the values
should reach us by mail.
I would like to give an example here
First we have to create a html form which will get the values from the user as
This form when submitted will be posted to a page called email.asp
In the file email.asp we will get the submitted values and send it as email
Code
<%
Dim objMail, objMailConf
Set objMail = Server.CreateObject("CDO.Message")
Set objMailConf = Server.CreateObject("CDO.Configuration")
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 '2 for web server
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:inetpubmailrootpickup"
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objMailConf.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
objMailConf.Fields.Update
Set objMail.Configuration = objMailConf
objMail.From = "someone@gmail.com"
objMail.To = Request.Form("To")
objMail.Subject = Request.Form("Subject")
objMail.TextBody = Request.Form("Body")
objMail.Fields.Update
objMail.Send
Set objMail = Nothing
Response.Write "Mail Sent Successfully"
%>
I would like to give an example here
First we have to create a html form which will get the values from the user as
This form when submitted will be posted to a page called email.asp
In the file email.asp we will get the submitted values and send it as email
Code
<%
Dim objMail, objMailConf
Set objMail = Server.CreateObject("CDO.Message")
Set objMailConf = Server.CreateObject("CDO.Configuration")
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 '2 for web server
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:inetpubmailrootpickup"
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objMailConf.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
objMailConf.Fields.Update
Set objMail.Configuration = objMailConf
objMail.From = "someone@gmail.com"
objMail.To = Request.Form("To")
objMail.Subject = Request.Form("Subject")
objMail.TextBody = Request.Form("Body")
objMail.Fields.Update
objMail.Send
Set objMail = Nothing
Response.Write "Mail Sent Successfully"
%>
No comments:
Post a Comment