Add data to database and it to an email???

  • Thread starter Thread starter Miguel Dias Moura
  • Start date Start date
M

Miguel Dias Moura

Hello,

i have an ASP.net / VB page with a Script (submitValues) and a Form.

1. The form has 10 input text and a "Submit" button.
2. The script declares 10 variables. The value of each variable is taken
from each of the 10 input texts.
3. When the button "Submit" is click the variable values are sent to an
email address using AspNetEmail.

As an example, the button code is this one:
<asp:Button ID="submit" runat="server" OnClick="submitValues"
Text="Submit"/>

What i want is to add a new record in a database and insert this values in
it. I allready created the dataSet to the database.

So, when the "Submit" button is clicked, the values are inserted in a new
record in the database and are also sent to my email.

Can you help me out?

Thanks,
Miguel
 
Can you help me out?

What specifically do you want help with?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
The script to send email is working.
The dataset which connects to the database is done.
What i want is the script or code to insert the form values in a new
record in the database when the button is submited.

Thank You,
Miguel
 
Try something like this:


Dim commentsender As New
SmtpClient(System.Configuration.ConfigurationManager.AppSettings("smtpserver"))
Dim commentmsg As New MailMessage(New
MailAddress("(e-mail address removed)"), New
MailAddress("(e-mail address removed)"))
commentmsg.IsBodyHtml = False
commentMsg.Subject = "Whatever Subject You Want"
commentMsg.Body = "The body of your outgoing email"
commentsender.Send(commentMsg)


You will need to import the System.Net.Mail namespace, and include the
following in your Web.config file:


<appSettings>
<add key="smtpserver" value="Your SMTP Server"/>
</appSettings>


For more information on the different properties and overloads of the
SmtpClient, MailMessage, MailAddress, and other classes used with emails,
see the documentation. The MailMessage.Body property is usually generated
using a System.Text.StringBuilder object, I simply used a static String in
the code above for simplicity. Good Luck!
 
Back
Top