Sub Test2()
Dim WsMail As Worksheet
Dim Chemin As String, FichierPDF As String, Destinataire As String, Contenu As String, Signature As String
Dim Nom As String, Prenom As String, MaDate As String, MonFichier As String
Dim MaMessagerie As Object, MonMessage As Object
Set WsMail = Sheets("Feuil1") '==========>> A' adapter
Chemin = "C:\Users\Username\Desktop\" '==========>> A' adapter
Application.ScreenUpdating = False
Nom = WsMail.Range("B10").Value
Prenom = WsMail.Range("B12").Value
MaDate = Format(WsMail.Range("C95").Value, "dd-mm-yyyy")
Destinataire = "monadresse1@mail.fr;monadresse2@mail.fr" '==========>> A' adapter
FichierPDF = Chemin & Nom & " " & Prenom & " " & MaDate & ".PDF"
Contenu = "<HTML><body>Bonjour " & Nom & " " & Prenom & ",<br>" & _
"veuillez trouver ci-joint le fichier Suivi " & Nom & " " & Prenom & " " & MaDate & " .<br>" & _
"Bien cordialement." & " </body>"
WsMail.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FichierPDF, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set MaMessagerie = CreateObject("Outlook.Application")
Set MonMessage = MaMessagerie.CreateItem(0)
With MonMessage
.Display
End With
Signature = MonMessage.htmlBody
With MonMessage
.To = Destinataire
.Subject = "Suivi " & Nom & " " & Prenom & " " & MaDate
.htmlBody = Contenu & Signature
.Attachments.Add FichierPDF
'affiche le message
.Display
'.Send '==========>> enlever l'apostrophe pour que le mail soit envoyé automatiquement
End With
Kill FichierPDF
Application.ScreenUpdating = True
End Sub