Foros del Web » Programando para Internet » ASPX (.net) »

Enviar formulario a un email

Estas en el tema de Enviar formulario a un email en el foro de ASPX (.net) en Foros del Web. Hola el codigo asp.net para enviar el formulario que tengo me salen algunos errores por que no he declarado unas variables o algo de eso ...
  #1 (permalink)  
Antiguo 27/03/2010, 17:02
 
Fecha de Ingreso: mayo-2009
Mensajes: 7
Antigüedad: 15 años
Puntos: 0
Enviar formulario a un email

Hola el codigo asp.net para enviar el formulario que tengo me salen algunos errores por que no he declarado unas variables o algo de eso mirenlo aver que tengo que hacer les dejo el html y el aspx.vb.
Gracias.

Imports System.Web.Mail

Partial Public Class _Default
Inherits System.Web.UI.Page

Protected Sub button_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.ServerClick
Dim correo As New System.Net.Mail.MailMessage()

correo.From = New System.Net.Mail.MailAddress(txtemail.text)
correo.To.Add("[email protected]")
correo.Subject = txtAsunto.Text
txtTexto.Text &= vbCrLf & vbCrLf & _
"Fecha y hora GMT: " & _
DateTime.Now.ToUniversalTime.ToString("dd/MM/yyyy HH:mm:ss")
correo.Body = txtTexto.Text
correo.IsBodyHtml = False
correo.Priority = System.Net.Mail.MailPriority.Normal
'
Dim smtp As New System.Net.Mail.SmtpClient

'---------------------------------------------
' Estos datos debes rellanarlos correctamente
'---------------------------------------------
smtp.Host = "smtp.mail.yahoo.com"
smtp.Credentials = New System.Net.NetworkCredential("usuario", "password")
smtp.EnableSsl = False
End Sub
End Class

Este es el html:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication3._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Página sin título</title>
</head>
<body>

<form id="form1" runat="server">
<div>
<form action="Default.aspx" method="post" name="form1" class="margenFotos_tarima" id="form2" enctype="text/plain">
<p>
<label for="nombre">Nombre</label>
<input type="text" name="nombre" id="nombre" />
<br />
<label for="apellidos">Apellidos</label>
<input type="text" name="apellidos" id="apellidos" />
<br />
<label for="email" runat="server">E-mail</label>
<input type="text" name="email" id="email" />
<br />
<label for="telefono">Teléfono</label>
<input type="text" name="telefono" id="telefono" />
<br />
<label for="direccion">Dirección</label>
<input type="text" name="direccion" id="direccion" />
<br />
<label for="poblacion">Población</label>
<input type="text" name="poblacion" id="poblacion" />
<br />
<span id="label">
<label for="comentario" class="textoComentario">Comentario</label>
</span>
<textarea name="comentario" cols="45" rows="5" id="comentario"></textarea>
</p>
<p>
<label for="button"></label>
<input name="button" type="submit" id="button" value="Enviar" runat="server" />
<br />
</p>
</form>
</div>
</form>
</body>
</html>

Etiquetas: email, enviar, formulario, aspx
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:55.