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
| Private Sub Commande137_Click()
On Error GoTo Commande137_Click_exit
'Envoi du mail avec le rapport en PJ
'Send mail
Dim objOL As Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
Dim ScrFile As String '= The report Name to output as PDF
Dim DestPath As String '= Destination path for PDF file
Dim DestFile As String 'File name for the PDF file being created without the file extension
Dim File As String
DestPath = CurrentProject.Path & "\Rapports_présaison\"
DestFile = Me.Num_rapport & ".pdf"
SrcFile = "Rapport_présaison"
File = DestPath & DestFile
If Dir(DestPath) = "" Then
MkDir DestPath
End If
If FileExists(File) = 0 Then
DoCmd.OutputTo acOutputReport, SrcFile, "PDFFormat(*.pdf)", File, 0, "", 0, acExportQualityPrint
End If
With objMail
.To = Me.email_MC.Value
.Cc = Forms![Infos_Joueurs].email
.Bcc = " "
.body = " "
.Subject = "Bilan présaison " & Me.Num_rapport.Value
.Attachments.Add (File)
.Display
'.Send
End With
Set objMail = Nothing
Set objOL = Nothing
Commande137_Click_exit:
MsgBox "Message Non envoyé!"
End Sub |
Partager