Created
April 26, 2017 23:22
-
-
Save RIENEGAN/42f659fc97546459baaff4bd3927b623 to your computer and use it in GitHub Desktop.
APP PROTOCOLO DE SMTP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''AUTENTFICACION SIMPLE | |
Public Class Autentificacion | |
Private Sub Validar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Validar.Click | |
If Password.Text = "1234" Then | |
Correo.Show() | |
Me.Hide() | |
Else | |
MsgBox("AUTENTIFICACION INCORRECTA. INTENTA DE NUEVO") | |
Password.Text = "" | |
End If | |
End Sub | |
End Class | |
''---------------------------------------------------------------------------------------------------------------------- | |
''SEGUNDA PARTE | |
''Importando modulos para SMTP | |
Imports System.Net.Mail | |
Imports System.Net | |
Imports System.Net.Mail.Attachment | |
''Nombre de la clase de la estructura del desarrollo | |
Public Class Correo | |
Dim Recopilar_Datos_De_Envio As New MailMessage | |
Dim Puerto As New SmtpClient | |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enviar_Correo.Click ''Boton Enviar_Correo | |
Dim Adjuntar As New Attachment(Ruta_Archivo.Text) | |
Recopilar_Datos_De_Envio.From = New MailAddress("[email protected]") ''Correo del server | |
Recopilar_Datos_De_Envio.To.Add(Destinatario.Text) ''Nombre del correo electronico | |
Recopilar_Datos_De_Envio.Body = Mensaje.Text ''Contenido del mensaje | |
Recopilar_Datos_De_Envio.Subject = Asunto.Text '' Asunto del remitente | |
Recopilar_Datos_De_Envio.Priority = System.Net.Mail.MailPriority.Normal '' la peticion debe ser un envio normal | |
''Adjuntando archivos | |
Recopilar_Datos_De_Envio.Attachments.Add(Adjuntar) | |
''configuracion del puerto saliente del smtp | |
Puerto.EnableSsl = True | |
Puerto.Port = "587" | |
''configurando el tipo de correo | |
Puerto.Host = "smtp.gmail.com""smtp.live.com" | |
''Autentificacion users | |
Puerto.Credentials = New Net.NetworkCredential("[email protected]", "*******") | |
Try | |
''Si contamos con la conexion, se hara la ejecucion del envio de los dato recabados | |
Puerto.Send(Recopilar_Datos_De_Envio) | |
MessageBox.Show("La Solicitud Ha Sido Enviado Correctamente Al Correo Electronico " & Destinatario.Text, "Correo") | |
Informacion_Enviada.Enabled = True | |
Recibido.Text = " ¡Usted Ha Mandado Al Siguiente Correo !:" & vbNewLine & Destinatario.Text | |
Informacion_Enviada.Text = Mensaje.Text | |
Destinatario.Text = "" | |
Mensaje.Text = "" | |
Asunto.Text = "" | |
''Si no contamos con la red, nos mandara avisar que debemos verificar | |
Catch ex As Exception | |
MessageBox.Show("INTENTE MAS TARDE...SOLICITUD CANCELADA, VERIFIQUE SU CONEXION DE RED, DEL PUERTO : " & Puerto.Port, | |
"LO SENTIMOS, NO TIENE CONEXION A LA RED O PROBLEMAS AL CARGAR ARCHIVO") | |
Destinatario.Text = "" | |
Mensaje.Text = "" | |
Asunto.Text = "" | |
End Try | |
End Sub | |
''aqui permite habilitat la casilla, y habilita la opc examinar para poder cargar archivos y enviarlos | |
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Habilitar_Casilla.CheckedChanged | |
Ruta_Archivo.Enabled = False | |
Examinar.Enabled = True | |
End Sub | |
''Este es el formulario completo donde estamos habilitando alguno componentes de la app | |
Private Sub Correo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load | |
MessageBox.Show("AUTENTIFICACION EXITOSA", "EMAIL MANDA MENSAJE DE ALERTA", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) | |
Ruta_Archivo.Enabled = False | |
Examinar.Enabled = False | |
End Sub | |
''Carga cualquier tipo de archivo en el boton examinar | |
Private Sub Examinar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Examinar.Click | |
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then | |
Ruta_Archivo.Text = OpenFileDialog1.FileName | |
End If | |
End Sub | |
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nuevo.Click | |
Ruta_Archivo.Text = "" | |
Mensaje.Text = "" | |
Asunto.Text = "" | |
End Sub | |
Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click | |
Close() | |
End Sub | |
Private Sub HabilitarPuertoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HabilitarPuertoToolStripMenuItem.Click | |
Puerto.EnableSsl = True | |
MsgBox("PUERTO HABILIDATO CORRECTAMENTE") | |
End Sub | |
Private Sub DeshabilitarPuertoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeshabilitarPuertoToolStripMenuItem.Click | |
Puerto.EnableSsl = False | |
MsgBox("POR EL MOMENTO NO PODRA ENVIAR INFORMACION") | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment