Private Sub CB_mail_Click()

    Dim OutApp As Application
    Dim oBjMail As Object
    Dim MyDate As String
    Dim MyAttachments As Object
    Dim Mem_Fichier As String
    Dim chemin As String
    Dim fichier As Variant
    Dim CurrentChart As Object
    Dim CR_Calcul_Month As Integer
    Dim Obj As Object


        nomPage = ActiveSheet.Name
        MyDate = Format(Date, "mmmm")
        CR_Calcul_Month = Worksheets("Bilan").Cells(12, 5).Value
         
        Set Obj = CreateObject("WScript.Shell")
        Set ObjOutlook = CreateObject("outlook.application")
        Set oBjMail = ObjOutlook.CreateItem(olMailItem)
        Set CurrentChart = Worksheets("Bilan").ChartObjects("Graph01").Chart                                    'selection le graph en image
        CurrentChart.Export Filename:=Application.ActiveWorkbook.Path & "\graph01.jpg", filtername:="JPG"       'enregistre le graph en image
        Application.Wait (Now + TimeValue("00:00:02"))                                                          'tempo de 2 secondes
        MyAttachements = Obj.SpecialFolders("Desktop") & "\graph01.jpg"                                         'charge l'image dans la variable MyAttachements

        If pj = "Faux" Then
        Exit Sub
        End If
        
        If VarType(pj) = vbBoolean Then
        Exit Sub
        End If

                 
            ' corps du mail avec renvoi de la variable du mois en cours + le calcul horaire de CM88 sur le mois en cours
            
            Corps = "Bonjour," & "<br>" _
            & "<br>" _
            & "Voici le compte rendu du taux d'occupation pour le mois de : " & MyDate _
            & "<br>" _
            & "<br>" _
            & "Le temps de travail sur CM88 pour le mois de " & MyDate & " est de : " _
            & CR_Calcul_Month _
            & "<br>" _
            & "<br>" _
            & "Cordialement"
            

        With oBjMail

            .To = "thurim29@xx.fr"                                           'adresse du destinataire
            .Subject = "TOJ du mois de " & MyDate                                             'objet du mail
            .HTMLBody = ""
            .BodyFormat = 2
            .Attachements.Add (MyAttachements)                                                'piece jointe
            .HTMLBody = Corps & oBjMail.HTMLBody
            .Display                                                                          'ouverture fenêtre mail
        End With
        
        Kill MyAttachements                                                                   'suppression de l'image sur le bureau
       
 
End Sub
