Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies

asp.net form mail noob

what code to use?

5:50 am on Mar 28, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:July 1, 2004
votes: 0

I'm doing a simple form mail in asp.net - I've figured out how to use the Visual Web Developer 2005 express edition to do the validation, but the form mail part escapes me. There is a tutorial on asp.net (the website) with video and the whole 9 yards BUT it glosses over the part I need, which is the really really basic (to everybody but me) how to set up the sendmail/cdonts/smtp part of the equation. Anybody have some simple code? I've got just 5 boneheaded text fields to email back, but I'm stumped on the basics. Here is my cry for help. HELP!
5:49 am on Apr 1, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Jan 23, 2004
votes: 0

I am not sure if understand your question, but if you need the code to create the SMTP object, this works for me:

<script language="vb" runat="server">
sub SendEmail(sender as Object, e as EventArgs)
dim mailclient as new SMTPClient("localhost")
Mailclient.send(Email.text, FROM EMAIL ADDRESS,SUBJECT,Comments.text)
end sub

I believe the code you are looking for is:
dim mailclient as new SMTPClient("localhost")

In the beginning of your ASP.NET file, you need to import the SMTP namespace using the following directive:

<%@ Import Namespace="System.Net.Mail" %>

I hope this helps,