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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
Option Explicit
Sub Mail()
Dim Destinataire As String
Dim sNomPdf As String
Dim sDossier As String
Dim sNomCrypt As String
Dim objApp As Object
Dim File As Object
Dim OutApp As Object
Dim objMessage As Object
Dim EmailApp As Outlook.Application
Dim Source As String
Set EmailApp = New Outlook.Application
sDossier = ThisWorkbook.Path
Destinataire = "monmail@outlook.com"
sNomPdf = sDossier & "\" & "Test.pdf"
Feuil1.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sNomPdf, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
sNomCrypt = sDossier & "\" & "Tempo.pdf"
EncryptPDFUsingPdfforgeDll sNomPdf, sNomCrypt
Kill sNomPdf
Name sNomCrypt As sNomPdf
Dim EmailItem As Outlook.MailItem
Set EmailItem = EmailApp.CreateItem(0)
EmailItem.To = Destinataire
EmailItem.CC = ""
EmailItem.BCC = ""
EmailItem.Subject = "Test"
EmailItem.HTMLBody = "Bonjour," & vbNewLine & vbNewLine & "Veuillez trouvez ci-joint votre Document. Votre mot de passe est ." & _
vbNewLine & vbNewLine & _
"Cordialement!," & vbNewLine & _
"Contact"
Source = ThisWorkbook.FullName
EmailItem.Attachments.Add ("C:\Users\bc00T349\Desktop\Test.pdf")
EmailItem.Send
Set objApp = Nothing
Set objMessage = Nothing
End Sub
Private Sub EncryptPDFUsingPdfforgeDll(sNomFichier As String, sOutputCrypt As String)
Dim Pdf As Object, Crypt As Object
Set Crypt = CreateObject("pdfforge.pdf.PDFEncryptor")
With Crypt
.AllowAssembly = False
.AllowCopy = False
.AllowFillIn = False
.AllowModifyAnnotations = False
.AllowModifyContents = False
.AllowPrinting = True
.AllowPrintingHighResolution = True
.AllowScreenReaders = False
.EncryptionMethod = 2
.OwnerPassword = "master"
.UserPassword = "master"
End With
Set Pdf = CreateObject("pdfforge.pdf.pdf")
Pdf.EncryptPDFFile sNomFichier, sOutputCrypt, Crypt
Set Pdf = Nothing
Set Crypt = Nothing
End Sub |
Partager