Sub MailAG()
'
' MailAG Macro
'
Dim Rep As Integer
Set sh = Sheets("Effectif")
With sh 'indiquer la feuille
dl = .Cells(Rows.Count, "AC").End(xlUp).Row
Set ol = CreateObject("Outlook.Application")
For i = 1 To dl
If .Cells(i, "P") <> "IEF" Then
If .Cells(i, "V") = "Oui" Then 'envoyer un mail ?
If .Cells(i, "W") = "" Then 'si déjà fait, la date s'affiche
Set olm = ol.CreateItem(0)
With olm
.To = "harold.letessier@abriasso.org" 'liste des mails
.Subject = "Documents de " & Sheets("Effectif").Cells(i, "C") 'titre du mail
.body = texte
For i = 1 To 10 'ici mettre ta boucle pas celle ci qui était pour test
texte = "Bonjour," & vbCrLf & vbCrLf & "dans le cadre de l'accompagnement de " & .Cells(i, "C") & " merci de nous faire parvenir "
If LCase(.Cells(i, "X")) = "non" And LCase(.Cells(i, "AC")) = "non" Then
texte = texte & "sa CMU et son RIB."
ElseIf LCase(.Cells(i, "X")) = "non" Then
texte = texte & "sa CMU."
ElseIf LCase(.Cells(i, "AC")) = "non" Then
texte = texte & "son RIB."
End If
texte = texte & vbCrLf & vbCrLf & "Cordialement"
'Debug.Print texte
Next i
End With
.Send
End With
.Cells(i, "V") = "Fait" 'remplace oui par fait
.Cells(i, "W") = Format(Now, "dd.m.yyyy") 'indique la date
Rep = MsgBox("Message envoyé à " & Cells(i, "Q").Value & " pour " & Cells(i, "C").Value, vbOKCancel) 'affiche le message des envois réalisés
If Rep = vbCancel Then Exit Sub
Else
End If
End If
End If
Next i
End With
End Sub
'