Está en la página 1de 2

Módulo_correo_PDF - 1

Sub correoeVpagsPDF()
Dim nfac, cliente, Email, ruta, LIBRO, ahora, ArchivoPdf As String
Dim ProgCorreo, CorreoSaliente As Object

With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With

Set nfac = Range("D2")


Set cliente = Range("B2")
Set Email = Range("H3")
ruta = ThisWorkbook.Path & "\Correoe\"
ahora = Application.WorksheetFunction.Text(Now(), "dd.mm.yy- hh.mm")
LIBRO = nfac & "-" & cliente & "-" & ahora & ".pdf"
ArchivoPdf = ruta & LIBRO

Set ProgCorreo = CreateObject("Outlook.Application")


Set CorreoSaliente = ProgCorreo.CreateItem(0)

With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ArchivoPdf, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With

On Error Resume Next


With CorreoSaliente
.to = Email
.CC = "anaxandridas100@gmail.com"
.BCC = ""
.Subject = "Envío de su factura nº " & nfac
.Body = "Estimados Sres.:" & Chr(13) & _
"Nos complace realizar el envío de la factura del asunto, según nuestro acuerdo." _
& Chr(13) & "Atentamente..."
.Attachments.Add ArchivoPdf
.Display 'o .Send para enviar sin ver
End With
On Error GoTo 0

Set CorreoSaliente = Nothing


Set ProgCorreo = Nothing

With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
End With
End Sub

Sub correoePresupPDF()
Dim nfpres, cliente, Email, ruta, LIBRO, ahora, ArchivoPdf As String
Dim ProgCorreo, CorreoSaliente As Object

With Application
Módulo_correo_PDF - 2

.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With

Set npres = Range("E2")


Set cliente = Range("G7")
Set Email = Range("D7")
ruta = ThisWorkbook.Path & "\Correoe\"
ahora = Application.WorksheetFunction.Text(Now(), "dd.mm.yy- hh.mm")
LIBRO = "P-" & npres & "-" & cliente & "-" & ahora & ".pdf"
ArchivoPdf = ruta & LIBRO

Set ProgCorreo = CreateObject("Outlook.Application")


Set CorreoSaliente = ProgCorreo.CreateItem(0)

With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ArchivoPdf, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With

On Error Resume Next


With CorreoSaliente
.to = Email
.CC = "anaxandridas100@gmail.com"
.BCC = ""
.Subject = "Envío de su presupuesto nº " & npres
.Body = "Estimados Sres.:" & Chr(13) & _
"Nos complace realizar el envío del presupuesto del asunto, según nuestro acuerdo." _
& Chr(13) & "Atentamente..."
.Attachments.Add ArchivoPdf
.Display 'o .Send para enviar sin ver
End With
On Error GoTo 0

'Kill ArchivoPdf

Set CorreoSaliente = Nothing


Set ProgCorreo = Nothing

With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
End With
End Sub

También podría gustarte