Hello friends:
I have the following code to send a report. My problem is how to replace the email adress "sepaal@yahoo.com" in the code (line in red), with the email adress inside the report I'm sending in the preliminary view. In the report I'm sending the email adress is in the "[Mail]" field. Thank you in advance for your help.
I have the following code to send a report. My problem is how to replace the email adress "sepaal@yahoo.com" in the code (line in red), with the email adress inside the report I'm sending in the preliminary view. In the report I'm sending the email adress is in the "[Mail]" field. Thank you in advance for your help.
Code:
Function Enviar_Recibo()
On Error GoTo Enviar_Recibo_Err
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Const sReport As String = "Recibo"
Dim sOutput As String
sOutput = Environ("Temp") & "\" & sReport & ".pdf"
If Len(Dir(sOutput)) > 0 Then Kill sOutput
DoCmd.OutputTo objecttype:=acOutputReport, _
objectname:=sReport, _
outputformat:=acFormatPDF, _
outputfile:=sOutput, _
outputquality:=acExportQualityPrint
Set oEmail = oApp.CreateItem(olMailItem)
[B][COLOR=rgb(226, 80, 65)] oEmail.To = "[email]sepaal@yahoo.com[/email]"[/COLOR][/B]
oEmail.Subject = "Recibo de pago "
oEmail.Body = "Estimados padres de familia:" & vbCrLf & _
" " & vbCrLf & _
"Enviamos archivo adjunto con su último recibo de pago realizado." & vbCrLf & _
" " & vbCrLf & _
"Agradecemos su apoyo para continuar con nuestra labor educativa." & vbCrLf & _
" " & vbCrLf & _
"Para cualquier aclaración comuníquense con el área de Control Escolar de la escuela." & vbCrLf & _
" " & vbCrLf & _
"Muchas gracias."
oEmail.Attachments.Add sOutput
With oEmail
If Not IsNull(.To) And Not IsNull(.Subject) And Not IsNull(.Body) Then
.Send
MsgBox "RECIBO ENVIADO"
Else
MsgBox "Indique el correo del destinatarios"
End If
End With
Enviar_Recibo_Exit:
Exit Function
Enviar_Recibo_Err:
MsgBox Error$
Resume Enviar_Recibo_Exit
End Function
Last edited by a moderator: