Private Sub ENVOIMAIL_Click()
Dim nb As Byte
Dim REF As Byte
Dim ADRESSE1 As Variant
Dim ADRESSE2 As Variant
DESTINATAIREMAIL = TextBox12
MAGAZIN = ActiveSheet.Name
NBLIGNELISTE = ListBox1.ListCount + 1
nb = 1 'le numero de ma variable "ADRESSE1"
For REF = 0 To NBLIGNELISTE
If ListBox1.Selected(REF) = True Then
lignemag = REF + 3
If Cells(lignemag, 14) < Cells(lignemag, 13) Then
Me.Controls("ADRESSE" & nb) = "K:\LEROY MERLIN\MAGASIN\" & MAGAZIN & "\" & Cells(lignemag, 17) & ".pdf"
nb = nb + 1 'le numero de ma variable "ADRESSE2"
End If
End If
Next REF
Dim ol As New Outlook.Application
Dim OLmail As MailItem
Set ol = New Outlook.Application
Set OLmail = ol.CreateItem(olMailItem)
With OLmail
.To = DESTINATAIREMAIL
.Subject = "Votre dossier pal " & MAGAZIN
.Body = "Bonjour Emilie et Virginie," & vbNewLine & vbNewLine & _
"" & vbNewLine & _
"Voilà votre fichier palette en date du" & DERNIEREDATE & vbNewLine & _
"" & vbNewLine & _
"Cordialement" & vbNewLine & _
"" & vbNewLine & _
"Vincent Blanc"
.Attachments.Add ADRESSE1
.Attachments.Add ADRESSE2
.display
'On peut switcher entre .send et .display selon que l'on veut envoyer le mail (send) ou seulement le préparer et le vérifier(display)
End With
End Sub