Connecting Tech Pros Worldwide Forums | Help | Site Map

Sending a simple Email

Newbie
 
Join Date: Sep 2008
Posts: 4
#1: Sep 29 '08
Hi! I'm newbie with ASP and I have a simple task to do. I should send email using IIS.
So I created html-file, which calls asp.page:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <form action="test.asp" method="POST">
  3. <input type="submit" VALUE="Send">
  4. </Form>
  5. </html>
The asp-page is another simple example, test.asp:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <%
  4. Set myMail=CreateObject("CDO.Message")
  5. myMail.Subject="Sending email with CDO"
  6. myMail.From="mymail@mydomain.com"
  7. myMail.To="mikko.bothas@digia.com"
  8. myMail.TextBody="This is a message."
  9. myMail.Send
  10. set myMail=nothing
  11. %>
  12. <h3> Message has been sent!
  13. </h3>
  14. </body>
  15. </html> 
When I open the html-file and press the submit button, all I see is the code inside the asp-file. So obviously this doesn't work. Any ideas what might be wrong?
I've added smtp-service to IIS and configured it to use smart host.
Any help is highly appreciated!
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 930
#2: Sep 29 '08

re: Sending a simple Email


Hi migi,

Are you running this website through the IIS? If not your ASP page will just be rendered as html which sounds like the case here.

If you need help setting up your website in IIS then let me know.

Dr B
Newbie
 
Join Date: Sep 2008
Posts: 4
#3: Sep 29 '08

re: Sending a simple Email


Quote:

Originally Posted by DrBunchman

Hi migi,

Are you running this website through the IIS? If not your ASP page will just be rendered as html which sounds like the case here.

If you need help setting up your website in IIS then let me know.

Dr B

Yes, we have IIS. But if you could guide me to use those two files, it would be great.
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 930
#4: Sep 30 '08

re: Sending a simple Email


Set up a virtual directory under the default website in the IIS, giving it a name and pointing it to the folder where your two files are. You should then be able to view them by browsing

//<servername>/<virtualdirectory>/<pagename>

So if you set up a virtual directory called Test on your local machine the URL would be

//127.0.0.1/Test/test.html

Submitting the form should now load the ASP page through the IIS correctly. Does this make sense? Let me know how it goes.

Dr B
Member
 
Join Date: Aug 2008
Posts: 48
#5: Oct 1 '08

re: Sending a simple Email


Actually your code is perfect

But it will not execute on localhost

after you host it on your web in any server

it will work fine..

try CDONTS.NewMail

Thank you

With Regards
JRK
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 930
#6: Oct 1 '08

re: Sending a simple Email


JRK,

Why won't it work on localhost? As long as the script is configured to use the default smtp service correctly it should work fine.

And why would use use CDONTS? CDONTS is a deprecated mail object and you should use CDOSYS nowadays.

Dr B
sashi's Avatar
Expert
 
Join Date: Jun 2006
Location: Seremban, Malaysia
Posts: 1,630
#7: Oct 1 '08

re: Sending a simple Email


Dear Everyone,

First of all i think someone has to brief her on setting up IIS on her XP box. Miqi, please take note, IIS is only supported on XP Pro version. Kindly follow the below links for further reading and research, happy coding.

1. Install & Configuring IIS on XP Pro

2.Configuring IIS Virtual SMTP Server
Reply


Similar ASP / Active Server Pages bytes