Sending mail using ASP.
-
Hi, How to send a mail using ASP? I am using windows server 2003. I want to have a form, in which user can enter name,email address and then in the submit button, send the mail. How to achieve this? Thank you
Thanks & Regards, Venkat
-
Hi, How to send a mail using ASP? I am using windows server 2003. I want to have a form, in which user can enter name,email address and then in the submit button, send the mail. How to achieve this? Thank you
Thanks & Regards, Venkat
-
Google (or Bing) is your friend! Lots of examples out there. Just search for net.mail example
Hi, I searched that. But I am not getting for using in windows server 2003. I tried the below code:
<%
Option Explicit
dim sName, sEmail, sMessage
dim oCdoMail, oCdoConf, sConfURLif Request.Form("Action") <> "" then
sName = Request.Form("Name")
sEmail = Request.Form("Email")
sMessage = Request.Form("Message")Set oCdoMail = Server.CreateObject("CDO.Message") Set oCdoConf = Server.CreateObject("CDO.Configuration") sConfURL = "http://schemas.microsoft.com/cdo/configuration/" with oCdoConf .Fields.Item(sConfURL & "sendusing") = 2 .Fields.Item(sConfURL & "smtpserver") = "server name" .Fields.Item(sConfURL & "smtpserverport") = 25 .Fields.Update end with with oCdoMail .From = "you@yourdomain.com" .To = sEmail .Subject = "My message subject" .TextBody = sMessage .HTMLBody = sMessage .Configuration = oCdoConf .Send end with Set oCdoConf = Nothing Set oCdoMail = Nothing response.write "Thanks for your message!"
else
%>
<form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<p>Name:<br /><input type="text" name="Name" /></p>
<p>E-mail:<br /><input type="text" name="Email" /></p>
<p>Message:<br /><textarea name="Message"></textarea></p>
<p><input type="submit" name="Action" value="Send" /></p>
</form>
<%
end if
%>But I am not getting the mail in inbox. Any help on this.. Thank you
Thanks & Regards, Venkat
modified on Tuesday, March 9, 2010 4:33 AM
-
Hi, I searched that. But I am not getting for using in windows server 2003. I tried the below code:
<%
Option Explicit
dim sName, sEmail, sMessage
dim oCdoMail, oCdoConf, sConfURLif Request.Form("Action") <> "" then
sName = Request.Form("Name")
sEmail = Request.Form("Email")
sMessage = Request.Form("Message")Set oCdoMail = Server.CreateObject("CDO.Message") Set oCdoConf = Server.CreateObject("CDO.Configuration") sConfURL = "http://schemas.microsoft.com/cdo/configuration/" with oCdoConf .Fields.Item(sConfURL & "sendusing") = 2 .Fields.Item(sConfURL & "smtpserver") = "server name" .Fields.Item(sConfURL & "smtpserverport") = 25 .Fields.Update end with with oCdoMail .From = "you@yourdomain.com" .To = sEmail .Subject = "My message subject" .TextBody = sMessage .HTMLBody = sMessage .Configuration = oCdoConf .Send end with Set oCdoConf = Nothing Set oCdoMail = Nothing response.write "Thanks for your message!"
else
%>
<form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<p>Name:<br /><input type="text" name="Name" /></p>
<p>E-mail:<br /><input type="text" name="Email" /></p>
<p>Message:<br /><textarea name="Message"></textarea></p>
<p><input type="submit" name="Action" value="Send" /></p>
</form>
<%
end if
%>But I am not getting the mail in inbox. Any help on this.. Thank you
Thanks & Regards, Venkat
modified on Tuesday, March 9, 2010 4:33 AM
-
What do the logs on the SMTP server say? I assume where it says "server name" you actually have the name of your server correct? Are you getting any error messages?
no sir it will not give a error because in this we have to define mail protocol name.. we can define SMTP,POP, etc.. but when we want to send mail not store then we can use SMTP protocol if we want to send mail as well as store then we use POP protocol.. so SMTP is not a server name its a type of protocol.. If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY
-
no sir it will not give a error because in this we have to define mail protocol name.. we can define SMTP,POP, etc.. but when we want to send mail not store then we can use SMTP protocol if we want to send mail as well as store then we use POP protocol.. so SMTP is not a server name its a type of protocol.. If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY
I don't think you understand. You can't use the POP protocol to send mail. To send mail you need to have an SMTP server. That server has a name. In the original poster's code he has the words "server name" as the name of the SMTP server. That would not be a valid server name. Before you try to correct someone, make sure you understand what they said.