Ver Mensaje Individual
  #11 (permalink)  
Antiguo 15/01/2013, 09:43
maialenlopez
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 11 meses
Puntos: 7
Respuesta: Mandar email con un boton

He echo lo siguiente:
Código vb.net:
Ver original
  1. Protected Sub enviarEmail(ByVal email As String)
  2.         Dim a, b, c, d, f, g, h As String
  3.         Try
  4.  
  5.             '* Creamos un Objeto tipo Mail
  6.             Dim objMail As Outlook.MailItem
  7.  
  8.             '* Inicializamos nuestra apliación OutLook
  9.             m_OutLook = New Outlook.Application
  10.  
  11.  
  12.             '* Creamos una instancia de un objeto tipo MailItem
  13.             objMail = m_OutLook.CreateItem(Outlook.OlItemType.olMailItem)
  14.  
  15.  
  16.             '* Asignamos las propiedades a nuestra Instancial del objeto
  17.             '* MailItem
  18.             'objMail.From = New System.Net.Mail.MailAddress(emailRemitente, emailRemitente, System.Text.Encoding.UTF8) 'Quien lo envía
  19.             objMail.To = email
  20.             objMail.Subject = "Hoja de gastos rechazada"
  21.  
  22.             Dim values As String = ""
  23.             For i As Integer = 0 To CheckBoxRechazo.Items.Count - 1
  24.                 If CheckBoxRechazo.Items(i).Selected Then
  25.                     If CheckBoxRechazo.Items(i).Value = 1 Then
  26.                         a = uno
  27.                     End If
  28.                     If CheckBoxRechazo.Items(i).Value = 2 Then
  29.                         b = dos
  30.                     End If
  31.                     If CheckBoxRechazo.Items(i).Value = 3 Then
  32.                         c = tres
  33.                     End If
  34.                     If CheckBoxRechazo.Items(i).Value = 4 Then
  35.                         d = cuatro
  36.                     End If
  37.                     If CheckBoxRechazo.Items(i).Value = 5 Then
  38.                         f = cinco
  39.                     End If
  40.                     If CheckBoxRechazo.Items(i).Value = 6 Then
  41.                         g = seis
  42.                     End If
  43.                 End If
  44.             Next
  45.  
  46.             h = TextObservacionesLG.Text
  47.  
  48.             objMail.Body = a + Chr(13) + b + Chr(13) + c + Chr(13) + d + Chr(13) + f + Chr(13) + g + Chr(13) + h
  49.  
  50.             'Prioridad del correo
  51.             objMail.Priority = System.Net.Mail.MailPriority.Normal
  52.  
  53.             'Host=nombre del servidor de correo por el que queremos enviar el mensaje
  54.             Dim smtp As New System.Net.Mail.SmtpClient
  55.             smtp.Host = "192.168.1.131"
  56.  
  57.             'Si el servidor de correo necesita autenticación
  58.             'smtp.Credentials = New System.Net.NetworkCredential("usuario", "password")
  59.  
  60.             '* Enviamos nuestro Mail y listo!
  61.             smtp.Send(objMail)
  62.             Label2.Text = "ENVIADO"
  63.             '* Desplegamos un mensaje indicando que todo fue exitoso
  64.             'MsgBox("Mail Enviado. Integración con OutLook")
  65.         Catch ex As Exception
  66.             Label2.Text = "NO ENVIADO"
  67.             '* Si se produce algun Error Notificar al usuario
  68.             'MsgBox("Error enviando mail " + ex.Message)
  69.         Finally
  70.             m_OutLook = Nothing
  71.             Response.Redirect("Identificador.aspx")
  72.         End Try
  73.     End Sub

No se si esta bien por que no consigo mandar ningún mail .

Me podeis ayudar??
__________________
Gracias por todo;

Un saludo