1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
Private Sub CommandButton1_Click()
'
' envoie un mail avec la pièce jointe en PDF
'
Dim ol As Object, monItem As Object
Set ol = CreateObject("outlook.application")
Set monItem = ol.CreateItem(olMailItem)
ChDrive "C:\"
ChDir "C:\Users\toto\Desktop"
ActiveDocument.ExportAsFixedFormat OutputFileName:=CurDir & "\" & "DeclarationIncident_" & Format(Date, "yyyy-mm-dd") & "_" & Format(Time, "hh-mm") & ".pdf", _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, Item:= _
wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
monItem.To = "toto@123456.fr"
monItem.Subject = "Déclaration d'incident" & Chr(13) & Date
monItem.Body = "Bonjour" & Chr(13) & Chr(13) & "Veuillez prendre connaissance de la déclaration d'incident en pièce jointe." & Chr(13) & Chr(13) & "Cordialement,"
Set mondoc = monItem.Attachments
mondoc.Add Replace(ActiveDocument.FullName, ".docm", ".pdf")
monItem.Send
Set ol = Nothing
MsgBox "Formulaire envoyé"
End Sub |
Partager