Sub EnvoyerMail()
'Microsoft Outkook xx.x Object Library
Dim xlWbk As Workbook
Dim xlWsh As Worksheet
Dim rngPlanning As Range
Dim strFilePath As String, strFolder As String, strPdfFile As String
Dim outApp As Outlook.Application
Dim outMail As Outlook.MailItem
Dim outAtt As Outlook.Attachment
Set xlWbk = ThisWorkbook
Set xlWsh = xlWbk.Worksheets("Mail")
Set rngPlanning = xlWsh.Range("D1:BF24")
strFilePath = ActiveWorkbook.Path & Application.PathSeparator
strFolder = "planning\"
strFilePath = strFilePath & strFolder
strPdfFile = Format(Now(), "yyyymmdd") & "_" & "Planning" & "_" & xlWsh.Range("BI6").Value & ".pdf"
rngPlanning.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=strFilePath & strPdfFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Debug.Print strFilePath & strPdfFile
Set outApp = New Outlook.Application
Set outMail = outApp.CreateItem(olMailItem)
With outMail
.BodyFormat = olFormatHTML
.Display
.HTMLBody = "Bonjour " & xlWsh.Range("BI6").Value & "<br>" & "<br>" & _
"Vous trouverez votre planning en attache." & "<br>" & "<br>" & _
"Bonne réception."
.To = xlWsh.Range("BK5").Value
.Subject = "Planning de la semaine n° " & xlWsh.Range("V3").Value
.Attachments.Add strFilePath & strPdfFile
.Display '.Send
End With
Set outMail = Nothing
Set outApp = Nothing
End Sub