Bonjour, ou faut-il que je place cette ensemble dans le module standard
Sub Mail()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim S As Shape
Dim sNomFic As String, sRep As String, WshShell As Object
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
' Créer une instance Windows Script pour retrouver le chemin du bureau
Set WshShell = CreateObject("WScript.Shell")
sRep = WshShell.SpecialFolders("Desktop")
Set WshShell = Nothing
' D_finit le nom du fichier ö enregistrer
sNomFic = "Registre de sortie des déchets" & Format(Date, "yyyymmdd") & ".pdf"
' Enregistrer la feuille en PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sRep & "\" & sNomFic, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set OutApp = CreateObject("outlook.application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "christophe.corvisier@nicecotedazur.org"
.CC = "robert.peters@nicecotedazur.org;sebastien.reynaud@nicecotedazur.org;denis.dibenedetto@nicecotedazur.org;christophe.corvisier@nicecotedazur.org"
.Attachments.Add (sRep & "\" & sNomFic)
.Subject = "Registre de sortie des déchets de Nice Ouest"""
.Body = "Nice, le " & Format(Date, "dd/mm/yy") & vbCrLf & vbCrLf
.Body = .Body & "Bonjour Gilles," & vbCrLf
.Body = .Body & "Objet : Registre de sortie des déchets de Nice Ouest" & vbCrLf & vbCrLf
.Body = .Body & "Tu trouveras ci-joint le registre de sortie des déchets sur Nice Ouest " & vbCrLf & vbCrLff
.Body = .Body & "Salutations cordiales" & vbCrLf
.Display
.Send 'envoi automatique
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & sNomFic)
End Sub