Jump to content

Where to put email form code?


Kaoru

Recommended Posts

I have the code for an email form, but I'm at a loss regarding where on the page to put it.I got the code from w3schools, but, I don't know whether or not to put it above the DOCTYPE and <html> declarations, or in the html code where I want the form to appear on the page.I'm an ASP newbie (only just started learning about a month ago) so I'm still not sure how things work.Any help would be appreciated.

Link to comment
Share on other sites

I have the code for an email form, but I'm at a loss regarding where on the page to put it.I got the code from w3schools, but, I don't know whether or not to put it above the DOCTYPE and <html> declarations, or in the html code where I want the form to appear on the page.
Officially, it doesn't really matter where you put the code. It can be above all other HTML, after all other HTML, or at any arbitrary point in between. However, as an unwritten rule of thumb, its best to group all of your ASP code into functions at the top of the page to seperate code logic from presentation and prevent excessive spaghetti code.
I'm an ASP newbie (only just started learning about a month ago) so I'm still not sure how things work.
My best advice is this: don't learn Classic ASP. Its a dead language now. Learn ASP.Net because the future of all web development is moving in a .Net direction, .Net is 10000000x more powerful than ASP*, and you'll waste too much time struggling in the future if you don't learn ASP.Net as soon as possible.* Classic ASP is really lacking in many important features, such as being able to generate MD5 hashes, file uploading, and image manipulation; to be able to get any of those functions, you have to write 100s of lines of custom code. ASP.net natively supports all of those functions (and 1000s more) in various namespaces, you can invoke any of those functions in 1 or 2 lines of code. ASP.net also has real datatypes, real page and control events, native support for XML and user memberships, etc.
Link to comment
Share on other sites

Below is the ASP code that I found to do (hopefully) what I want done:

<%Set myMail=CreateObject("CDO.Message")myMail.Subject="Sending email with CDO"myMail.From="mymail@mydomain.com"myMail.To="someone@somedomain.com"myMail.HTMLBody = "<h1>This is a message.</h1>" myMail.Sendset myMail=nothing%>

Does this differ at all from the asp.NET code that does the same thing? I've been looking, but I can't find asp.NET code...

Link to comment
Share on other sites

The code you posted sends mail, you can put it anywhere in the page and it will send mail. but if you want to do something like create a form and let the user fill in the message and their email and you want that message to be emailed to you, then it will be different. what is that you want to do?

Does this differ at all from the asp.NET code that does the same thing? I've been looking, but I can't find asp.NET code...
Its different in ASP.NET 1.1....http://www.developer.com/net/asp/article.php/3096831
Link to comment
Share on other sites

Does this differ at all from the asp.NET code that does the same thing? I've been looking, but I can't find asp.NET code...
Here's how you could send a message in ASP.NET (C#):
MailMessage message = new MailMessage("mymail@mydomain.com", "someone@somedomain.com");message.Subject = "Sending email with .NET";message.Body = "<h1>This is a message.</h1>";message.IsHtml = true;SmtpClient mailer = new SmtpClient("mail.somedomain.com");mailer.Send(message);

To further what Yahweh was saying about ASP being a dying language and learning ASP.NET instead, I would only add that you should go the C# route rather than the VB route.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...