Título: Correo desde Visual Basic???? Publicado por: CeLaYa en 5 Octubre 2006, 22:33 pm Alguien sabe como enviar un mail desde una aplicaion de VB6, de antemano gracias
Título: Re: Correo desde Visual Basic???? Publicado por: CeLaYa en 5 Octubre 2006, 23:20 pm creo que ya lo solucione
en un command pongo MAPISession1.SignOn MAPIMessages1.SessionID = MAPISession1.SessionID ComposeMessage MAPISession1.SignOff y luego en un sub Private Sub ComposeMessage() On Error GoTo ComposeErr Dim strMessage As String MAPIMessages1.Compose 'MAPIMessages1.MsgIndex = -1 MAPIMessages1.RecipDisplayName = "ocelaya@contal.com" MAPIMessages1.MsgSubject = "Soporte técnico" MAPIMessages1.Send True Exit Sub ComposeErr: Debug.Print Err.Number, Err.Description Resume Next End Sub lo pongo por a alguien le sirve Título: Re: Correo desde Visual Basic???? Publicado por: xDie en 5 Octubre 2006, 23:51 pm Pero ahi no envia un mail te abre el outlock ara que lo mandes xD, si sigues interesado como mandar tengo un metodo con un archivito php, y control Inet ;)
Título: Re: Correo desde Visual Basic???? Publicado por: WarGhost en 6 Octubre 2006, 00:02 am lo de enviar correos es jodido sobre todo si es para spam porque usar un código php en un servidor normal mente si es gratuito es bloqueado y si es de pago gastas mucho ancho.
lo mas eficaz es crear un servidor smtp en local y enviarlo por ese. Título: Re: Correo desde Visual Basic???? Publicado por: CeLaYa en 6 Octubre 2006, 01:23 am Lo que estoy haciendo en una aplicación en donde quiero incluir una parte de soporte técnico, asi para que los usuarios puedan mandarme un mail en caso de alguna falla o comentario, es cierto que abro el Outlook, pero la verdad no me se otra forma, si pueden ayudarme se los agradeceria mucho
Título: Re: Correo desde Visual Basic???? Publicado por: Gorky en 6 Octubre 2006, 09:27 am No me gusta ser aguafiestas pero antes de hacer una pregunta deberias buscar un poco. Y con mucho mas motivo si la pregunta ya esta respondida en un tema que se llama:
Citar Recopilación de enlaces de Visual Basic (LEER ANTES DE PREGUNTAR) Aqui lo tienes todo clarito: Mandar mail por SMTP http://foro.elhacker.net/index.php/topic,72560.0.html Título: Re: Correo desde Visual Basic???? Publicado por: WarGhost en 6 Octubre 2006, 10:59 am una duda a alguien a conseguido enviar algún email desde un servidor smtp tipo Yahoo, hotmal, gmail yo creo que no porque tienen los filtros y no llegan osea que no sirve.
Título: Re: Correo desde Visual Basic???? Publicado por: xDie en 6 Octubre 2006, 18:41 pm una duda a alguien a conseguido enviar algún email desde un servidor smtp tipo Yahoo, hotmal, gmail yo creo que no porque tienen los filtros y no llegan osea que no sirve. Yo probe hace pòco con hotmail, con 3 servidores distintos y nucna llegan Título: Re: Correo desde Visual Basic???? Publicado por: CeLaYa en 6 Octubre 2006, 23:13 pm ya cheque el link que me recomendaron pero no hace nada, hay alguna otra forma???
Título: Re: Correo desde Visual Basic???? Publicado por: katanaia en 7 Octubre 2006, 01:55 am Queria acotar que tambien estoy interesado pero si el metodo me permite evadir los filtros antispam de yahoo y hotmail. Alguien sabe como hace el famoso worm Skynet? Infecta a miles de usuarios a diario y encabeza el ranking de infecciones... infectará solamente a las direcciones que no tienen filtros para spam??? :huh:
Título: Re: Correo desde Visual Basic???? Publicado por: CeLaYa en 10 Octubre 2006, 15:35 pm por fin he encontrado la forma de enviar el correo, el codigo lo saque de un ejemplo de esta pag http://www.controltotal.org/VB/tipos/Pinternet.htm
Private Sub btnSend_Click() Winsock1.RemoteHost = txHost Winsock1.RemotePort = 25 Winsock1.Connect End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) ' this is the main processing code for ' sending an email message ' the iState variable maintains the current ' state of the protocol exchange so that we ' know what to send next Dim strData As String Static iState As Integer Dim iMsgNum As Integer Dim szMsg As String Dim I As Integer Winsock1.GetData strData, vbString iMsgNum = Val(Left(strData, InStr(strData, " "))) Select Case iMsgNum Case 220 ' initial message Winsock1.SendData "HELO " & txHost & vbCrLf txStatus = "Mail Server is ready..." iState = 1 Case 221 If iState = 999 Then txStatus = "Disconnected from mail server after error..." Else txStatus = "Disconnected from mail server..." End If iState = 0 Case 250 Select Case iState Case 1: Winsock1.SendData "MAIL FROM:<" & txFrom & ">" & vbCrLf Debug.Print "MAIL FROM:<" & txFrom & ">" & vbCrLf txStatus = "Sending FROM command..." iState = 2 Case 2: Winsock1.SendData "RCPT TO:<" & txTo & ">" & vbCrLf Debug.Print "RCPT TO:<" & txTo & ">" & vbCrLf txStatus = "Sending RCPT command..." iState = 3 Case 3: Winsock1.SendData "DATA" & vbCrLf Debug.Print "DATA" & vbCrLf txStatus = "Sending DATA command..." iState = 4 Case 5: Winsock1.SendData "QUIT" & vbCrLf Debug.Print "QUIT" & vbCrLf txStatus = "Sending Quit command to disconnecting from mail server..." iState = 6 Winsock1.Close End Select Case 354 iState = 5 szMsg = txMessage txStatus = "Sending mail message data..." Winsock1.SendData "Subject: " & txSubject & vbCrLf While szMsg <> "" Winsock1.SendData Left(szMsg, InStr(szMsg, Chr(10))) Debug.Print "Sending:" & Left(szMsg, InStr(szMsg, Chr(10))) szMsg = Mid(szMsg, InStr(szMsg, Chr(10)) + 1) Wend Winsock1.SendData "." & vbCrLf Case 500 To 599 Winsock1.SendData "QUIT" & vbCrLf txStatus = "Error sending mail..." Debug.Print "Error sending mail... quitting..." iState = 999 End Select End Sub Título: Re: Correo desde Visual Basic???? Publicado por: soplo en 10 Octubre 2006, 21:33 pm Pues ahora te pongo un reto:
busca la manera de encapsular ese código de forma que consigas un control que puedas insertar en un formulario y que tenga las propiedades 'para', 'de' y 'asunto' jajaja Título: Re: Correo desde Visual Basic???? Publicado por: CeLaYa en 10 Octubre 2006, 21:45 pm trato hecho
Título: Re: Correo desde Visual Basic???? Publicado por: CeLaYa en 10 Octubre 2006, 23:24 pm ya esta listo el OCX que hace la funcion de enviar correo, pero mi duda ahora es: ¿¿¿¿Como le hago para ponerlo aqui y lo pueadan descargar??? , disculpen mi ignorancia
Título: Re: Correo desde Visual Basic???? Publicado por: WarGhost en 10 Octubre 2006, 23:52 pm una duda y que servidor usas porque vamos casi ningun funciona.
Título: Re: Correo desde Visual Basic???? Publicado por: CeLaYa en 11 Octubre 2006, 17:17 pm bueno ya lo puse aqui, es un ocx muy sencillo, voy a tratar de ir agregando cosas, si a alguien se le ocurre algo pues vemos como lo modificamos
http://www.geocities.com/cero780814/EnviarCorreo.zip Título: Re: Correo desde Visual Basic???? Publicado por: soplo en 11 Octubre 2006, 21:23 pm Ale!
A manuales, tutoriales y ejemplos Gracias Celaya ;D Título: Re: Correo desde Visual Basic???? Publicado por: CeLaYa en 11 Octubre 2006, 22:52 pm hay les va el código....
agrege un cotrol de usuario y en el puse un winsock(wsMail), 5 textbox(txtServidor, txtDe, txtPara, txtAsunto y txtMensaje) y un xpcmdbutton(cmdEnviar) Código: 'Event Declarations: Event Enviar() 'MappingInfo=cmdEnviar,cmdEnviar,-1,Click Código: Private Sub cmdEnviar_Click() RaiseEvent Enviar wsMail.RemoteHost = txtServidor.Text wsMail.RemotePort = 25 wsMail.Connect End Sub Código: Private Sub UserControl_Resize() On Local Error Resume Next txtServidor.Width = UserControl.ScaleWidth - txtServidor.Left * 2 txtDe.Width = UserControl.ScaleWidth - txtServidor.Left * 2 txtPara.Width = UserControl.ScaleWidth - txtServidor.Left * 2 txtAsunto.Width = UserControl.ScaleWidth - txtServidor.Left * 2 txtMensaje.Width = UserControl.ScaleWidth - txtServidor.Left * 2 txtMensaje.Height = UserControl.ScaleHeight - txtMensaje.Top - 540 cmdEnviar.Top = txtMensaje.Top + txtMensaje.Height + 100 cmdEnviar.Left = UserControl.ScaleWidth - cmdEnviar.Width - 100 txStatus.Width = UserControl.ScaleWidth txStatus.Top = UserControl.ScaleHeight - txStatus.Height On Local Error Resume Next End Sub Código: Private Sub wsMail_DataArrival(ByVal bytesTotal As Long) ' this is the main processing code for ' sending an email message ' the iState variable maintains the current ' state of the protocol exchange so that we ' know what to send next Dim strData As String Static iState As Integer Dim iMsgNum As Integer Dim szMsg As String Dim I As Integer wsMail.GetData strData, vbString iMsgNum = Val(Left(strData, InStr(strData, " "))) Select Case iMsgNum Case 220 ' initial message wsMail.SendData "HELO " & txtServidor.Text & vbCrLf txStatus = "Servidor de correo conectado..." iState = 1 Case 221 If iState = 999 Then txStatus = "Desconectado del servidor de coreo con errores..." Else txStatus = "Desconectado del servidor de coreo..." End If iState = 0 Case 250 Select Case iState Case 1: wsMail.SendData "MAIL FROM:<" & txtDe.Text & ">" & vbCrLf 'Debug.Print "MAIL FROM:<" & txtMail.Text & ">" & vbCrLf txStatus = "Enviando comando FROM..." iState = 2 Case 2: wsMail.SendData "RCPT TO:<" & txtPara.Text & ">" & vbCrLf 'Debug.Print "RCPT TO:<ocelaya@embzacatecas.com>" & vbCrLf txStatus = "Enviando comando RCPT..." iState = 3 Case 3: wsMail.SendData "DATA" & vbCrLf 'Debug.Print "DATA" & vbCrLf txStatus = "Enviando comando DATA..." iState = 4 Case 5: wsMail.SendData "QUIT" & vbCrLf 'Debug.Print "QUIT" & vbCrLf txStatus = "Enviando comando Quit para desconecar del servidor de correo..." iState = 6 wsMail.Close MsgBox "Su correo ha sido enviado correctamente.", vbInformation + vbOKOnly, "Soporte técnico" End Select Case 354 iState = 5 szMsg = txtMensaje.Text + Chr(10) txStatus = "Sending mail message data..." wsMail.SendData "Subject: " & txtAsunto.Text & vbCrLf While szMsg <> "" wsMail.SendData Left(szMsg, InStr(szMsg, Chr(10))) 'Debug.Print "Sending:" & Left(szMsg, InStr(szMsg, Chr(10))) szMsg = Mid(szMsg, InStr(szMsg, Chr(10)) + 1) Wend wsMail.SendData "." & vbCrLf Case 500 To 599 wsMail.SendData "QUIT" & vbCrLf txStatus = "Error al enviar el correo..." 'Debug.Print "Error sending mail... quitting..." iState = 999 End Select End Sub 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=UserControl,UserControl,-1,BackColor Código: Public Property Get BackColor() As OLE_COLOR BackColor = UserControl.BackColor End Property Código: Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR) UserControl.BackColor() = New_BackColor PropertyChanged "BackColor" End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=UserControl,UserControl,-1,ForeColor Código: Public Property Get ForeColor() As OLE_COLOR ForeColor = UserControl.ForeColor End Property Código: Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR) UserControl.ForeColor() = New_ForeColor PropertyChanged "ForeColor" txtServidor.ForeColor = New_ForeColor txtDe.ForeColor = New_ForeColor txtPara.ForeColor = New_ForeColor txtAsunto.ForeColor = New_ForeColor txtMensaje.ForeColor = New_ForeColor lblServidor.ForeColor = New_ForeColor lblDe.ForeColor = New_ForeColor lblPara.ForeColor = New_ForeColor lblAsunto.ForeColor = New_ForeColor lblMensaje.ForeColor = New_ForeColor End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=UserControl,UserControl,-1,Enabled Código: Public Property Get Enabled() As Boolean Enabled = UserControl.Enabled End Property Código: Public Property Let Enabled(ByVal New_Enabled As Boolean) UserControl.Enabled() = New_Enabled PropertyChanged "Enabled" End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=UserControl,UserControl,-1,Font Código: Public Property Get Font() As Font Set Font = UserControl.Font End Property Código: Public Property Set Font(ByVal New_Font As Font) Set UserControl.Font = New_Font PropertyChanged "Font" txtServidor.Font = New_Font txtDe.Font = New_Font txtPara.Font = New_Font txtAsunto.Font = New_Font txtMensaje.Font = New_Font lblServidor.Font = New_Font lblDe.Font = New_Font lblPara.Font = New_Font lblAsunto.Font = New_Font lblMensaje.Font = New_Font End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=UserControl,UserControl,-1,Appearance Código: Public Property Get Appearance() As Integer Appearance = UserControl.Appearance End Property Código: Public Property Let Appearance(ByVal New_Appearance As Integer) UserControl.Appearance() = New_Appearance PropertyChanged "Appearance" txtServidor.Appearance = New_Appearance txtDe.Appearance = New_Appearance txtPara.Appearance = New_Appearance txtAsunto.Appearance = New_Appearance txtMensaje.Appearance = New_Appearance End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=UserControl,UserControl,-1,BackStyle Código: Public Property Get BackStyle() As Integer BackStyle = UserControl.BackStyle End Property Código: Public Property Let BackStyle(ByVal New_BackStyle As Integer) UserControl.BackStyle() = New_BackStyle PropertyChanged "BackStyle" End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=UserControl,UserControl,-1,BorderStyle Código: Public Property Get BorderStyle() As Integer BorderStyle = UserControl.BorderStyle End Property Código: Public Property Let BorderStyle(ByVal New_BorderStyle As Integer) UserControl.BorderStyle() = New_BorderStyle PropertyChanged "BorderStyle" End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=UserControl,UserControl,-1,Refresh Código: Public Sub Refresh() UserControl.Refresh End Sub 'Inicializar propiedades para control de usuario Código: Private Sub UserControl_InitProperties() Set UserControl.Font = Ambient.Font End Sub 'Cargar valores de propiedad desde el almacén Código: Private Sub UserControl_ReadProperties(PropBag As PropertyBag) UserControl.BackColor = PropBag.ReadProperty("BackColor", &H8000000F) UserControl.ForeColor = PropBag.ReadProperty("ForeColor", &H80000012) UserControl.Enabled = PropBag.ReadProperty("Enabled", Verdadero) Set UserControl.Font = PropBag.ReadProperty("Font", Ambient.Font) UserControl.Appearance = PropBag.ReadProperty("Appearance", 1) UserControl.BackStyle = PropBag.ReadProperty("BackStyle", 1) UserControl.BorderStyle = PropBag.ReadProperty("BorderStyle", 0) txtServidor.Text = PropBag.ReadProperty("Servidor", "") txtDe.Text = PropBag.ReadProperty("De", "") txtPara.Text = PropBag.ReadProperty("Para", "") txtAsunto.Text = PropBag.ReadProperty("Asunto", "") txtMensaje.Text = PropBag.ReadProperty("Mensaje", "") End Sub 'Escribir valores de propiedad en el almacén Código: Private Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("BackColor", UserControl.BackColor, &H8000000F) Call PropBag.WriteProperty("ForeColor", UserControl.ForeColor, &H80000012) Call PropBag.WriteProperty("Enabled", UserControl.Enabled, Verdadero) Call PropBag.WriteProperty("Font", UserControl.Font, Ambient.Font) Call PropBag.WriteProperty("Appearance", UserControl.Appearance, 1) Call PropBag.WriteProperty("BackStyle", UserControl.BackStyle, 1) Call PropBag.WriteProperty("BorderStyle", UserControl.BorderStyle, 0) Call PropBag.WriteProperty("Servidor", txtServidor.Text, "") Call PropBag.WriteProperty("De", txtDe.Text, "") Call PropBag.WriteProperty("Para", txtPara.Text, "") Call PropBag.WriteProperty("Asunto", txtAsunto.Text, "") Call PropBag.WriteProperty("Mensaje", txtMensaje.Text, "") End Sub 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=txtServidor,txtServidor,-1,Text Código: Public Property Get Servidor() As String Servidor = txtServidor.Text End Property Código: Public Property Let Servidor(ByVal New_Servidor As String) txtServidor.Text() = New_Servidor PropertyChanged "Servidor" End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=txtDe,txtDe,-1,Text Código: Public Property Get De() As String De = txtDe.Text End Property Código: Public Property Let De(ByVal New_De As String) txtDe.Text() = New_De PropertyChanged "De" End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=txtPara,txtPara,-1,Text Código: Public Property Get Para() As String Para = txtPara.Text End Property Código: Public Property Let Para(ByVal New_Para As String) txtPara.Text() = New_Para PropertyChanged "Para" End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=txtAsunto,txtAsunto,-1,Text Código: Public Property Get Asunto() As String Asunto = txtAsunto.Text End Property Código: Public Property Let Asunto(ByVal New_Asunto As String) txtAsunto.Text() = New_Asunto PropertyChanged "Asunto" End Property 'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS 'MappingInfo=txtMensaje,txtMensaje,-1,Text Código: Public Property Get Mensaje() As String Mensaje = txtMensaje.Text End Property Código: Public Property Let Mensaje(ByVal New_Mensaje As String) txtMensaje.Text() = New_Mensaje PropertyChanged "Mensaje" End Property Título: Re: Correo desde Visual Basic???? Publicado por: Empresario2.0 en 24 Febrero 2008, 21:06 pm Al final como se hace, por que debe haber un modo correcto de hacerlo o si no, el outlook no funcionaria.
si alguien sabe que me escriba gracias brain.networks@gmail.com Título: Re: Correo desde Visual Basic???? Publicado por: fffher en 23 Abril 2008, 18:20 pm oigan
i si si funciona no karga el zip pero dejemos eso komo le hago para mandar el mail kon imagenes en el mensaje rich text box en adjuntos si se como pero en rich text box para que me acepte imagenes tmb pero al ahora de mandarlo y chekar el mail me envia cifrada la imagen uso el server de gmail y otros pero no se eso tenag que ver Título: Re: Correo desde Visual Basic???? Publicado por: Pox1 en 23 Abril 2008, 22:05 pm Hola,Yo he utilizado el que hizo Luciano y la verdad que funciona de las mil maravillas utilizando la referencia a Microsoft CDO for windows 2000 library, se puede usar de muchas formas sólo pensar un poquito...
Ahi esta el Link: http://www.recursosvisualbasic.com.ar/htm/trucos-codigofuente-visual-basic/337-enviar-correo-en-vb-con-microsoft-cdo.htm Suerte a todos. |