Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/01/2010, 20:00
Avatar de STK_Pablo
STK_Pablo
 
Fecha de Ingreso: junio-2008
Ubicación: Las Rosas - Santa Fe - Argentina
Mensajes: 69
Antigüedad: 15 años, 10 meses
Puntos: 1
Respuesta: Email con VB6

Mira, yo utilizo esta rutina que lo que realiza es enviar el mail al Outlook y desde alli se envia al destinatario.... Posee varias opciones porque yo la utilizo en un sistema que envio distyintos tipos de email y los tengo personalizados con templates pero es bastante sencillo de entender, espero te sirva:

Código vb:
Ver original
  1. Public Sub EnviarEmail(emlTO As String, Optional emlPROFESIONAL As String = "", Optional emlPACIENTE As String = "", Optional emlADJUNTOS As String = "", Optional emlTITULO As String = "[ROA srl] - Informe de Estudio", Optional emlTEMPLATE As String = "DEFAULT")
  2.   ' Iniciar Outlook.
  3.  ' Si ya se está ejecutando, utilizará la misma instancia...
  4.  Dim olApp As Outlook.Application
  5.   Dim imgs() As String
  6.   Dim adjuntos() As String
  7.   Dim emlBODY As String
  8.   Set olApp = CreateObject("Outlook.Application")
  9.   'Inicio de sesión. No importa si ya lo está ejecutando y tiene iniciada una sesión...
  10.  Dim olNs As Outlook.NameSpace
  11.   Set olNs = olApp.GetNamespace("MAPI")
  12.   olNs.Logon
  13.   ' Enviar un mensaje
  14.  Dim olMail As Outlook.MailItem
  15.   Set olMail = olApp.CreateItem(olMailItem)
  16.   olMail.BodyFormat = olFormatHTML
  17.   olMail.ReadReceiptRequested = True      'Solicito confirmación de lectura
  18.  olMail.OriginatorDeliveryReportRequested = True
  19.   ' Rellenar y enviar el mensaje...
  20.  'Cargar datos pasados como parametros
  21.  If SISTEMA_DEBUG Then
  22.     olMail.To = "[email protected]"
  23.   Else
  24.     olMail.To = emlTO
  25.   End If
  26.   olMail.Subject = emlTITULO
  27.   'Levanto desde la configuracion del template
  28.  oSQL = "SELECT * FROM templates WHERE nombre = '" & emlTEMPLATE & "';"
  29.   ConectarDB
  30.   CrearRST (oSQL)
  31.   If Not stkRST.EOF Then
  32.     imgs = Split(stkRST!IMAGENES, ";")
  33.     For Cont = LBound(imgs) To UBound(imgs)
  34.       olMail.Attachments.Add App.Path & "\graphs\templates\" & imgs(Cont)
  35.     Next Cont
  36.     emlBODY = Replace(stkRST!Body, "<-PROFESIONAL->", emlPROFESIONAL)
  37.     emlBODY = Replace(emlBODY, "<-PACIENTE->", emlPACIENTE)
  38.     olMail.HTMLBody = emlBODY
  39.   Else
  40.     MsgBox "ERROR: No se encuentra el TEMPLATE solicitado"
  41.   End If
  42.   CortarDB
  43.   'Imagenes adjuntas...
  44.  If emlADJUNTOS <> "" Then
  45.     adjuntos = Split(emlADJUNTOS, "|")
  46.     For Cont = LBound(adjuntos) To UBound(adjuntos)
  47.       olMail.Attachments.Add adjuntos(Cont)
  48.     Next Cont
  49.   End If
  50.   olMail.Save
  51.   olMail.Send
  52.   olNs.Logoff
  53.   Set olNs = Nothing
  54.   Set olMail = Nothing
  55.   Set olApp = Nothing
  56. End Sub

No te olvides de hacer referencia desde tu proyecto a la libreria del Microsoft Outlook xx.xx Object Library

Eso es todo
__________________
- StrockerSoft - Software Factory -
Las Rosas - Santa Fe - argentina