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 originalPublic 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")
' Iniciar Outlook.
' Si ya se está ejecutando, utilizará la misma instancia...
Dim olApp As Outlook.Application
Dim imgs() As String
Dim adjuntos() As String
Dim emlBODY As String
Set olApp = CreateObject("Outlook.Application")
'Inicio de sesión. No importa si ya lo está ejecutando y tiene iniciada una sesión...
Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon
' Enviar un mensaje
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
olMail.BodyFormat = olFormatHTML
olMail.ReadReceiptRequested = True 'Solicito confirmación de lectura
olMail.OriginatorDeliveryReportRequested = True
' Rellenar y enviar el mensaje...
'Cargar datos pasados como parametros
If SISTEMA_DEBUG Then
Else
olMail.To = emlTO
End If
olMail.Subject = emlTITULO
'Levanto desde la configuracion del template
oSQL = "SELECT * FROM templates WHERE nombre = '" & emlTEMPLATE & "';"
ConectarDB
CrearRST (oSQL)
If Not stkRST.EOF Then
imgs = Split(stkRST!IMAGENES, ";")
For Cont = LBound(imgs) To UBound(imgs)
olMail.Attachments.Add App.Path & "\graphs\templates\" & imgs(Cont)
Next Cont
emlBODY = Replace(stkRST!Body, "<-PROFESIONAL->", emlPROFESIONAL)
emlBODY = Replace(emlBODY, "<-PACIENTE->", emlPACIENTE)
olMail.HTMLBody = emlBODY
Else
MsgBox "ERROR: No se encuentra el TEMPLATE solicitado"
End If
CortarDB
'Imagenes adjuntas...
If emlADJUNTOS <> "" Then
adjuntos = Split(emlADJUNTOS, "|")
For Cont = LBound(adjuntos) To UBound(adjuntos)
olMail.Attachments.Add adjuntos(Cont)
Next Cont
End If
olMail.Save
olMail.Send
olNs.Logoff
Set olNs = Nothing
Set olMail = Nothing
Set olApp = Nothing
End Sub
No te olvides de hacer referencia desde tu proyecto a la libreria del
Microsoft Outlook xx.xx Object Library
Eso es todo