Sub envoilta()
Dim TempFilePath As String
Dim TempFileName As String
Dim Destwb As Workbook
Dim OutApp As Object
Dim OutMail As Object
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Destwb = ActiveWorkbook
TempFilePath = Environ$("temp") & "\"
TempFileName = ActiveSheet.Name
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With Destwb
With .ActiveSheet.PageSetup
.PrintArea = "$A:$L"
.Orientation = xlLandscape
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=TempFilePath & TempFileName & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False '
On Error Resume Next
With OutMail
.to = "@gmail.com"
.CC = "@gmail.com"
.BCC = ""
.Subject = "Envoie LTA LMP TLS"
.Body = "Bonjour, Merci de trouver ci joint la LTA du prochain envoie. Cordialement"
.Attachments.Add TempFilePath & TempFileName & ".pdf"
.Send
'.display
End With
On Error GoTo 0
'.Close savechanges:=False
End With
Kill TempFilePath & TempFileName & ".pdf"
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub