Sub EnvoyerMailEtPDF()
'Dim objMessage As Object
Dim objMessage As CDO.Message
Dim sNomPDF As String, sCheminPDF As String
Dim [COLOR=green]Prenom[/COLOR] As String, AdresMail As String, Msg As String, [COLOR=red]DebJournee[/COLOR] As String
Dim DCarteVal As Date, j As Long, c As Range, lig As Long
'---- Création et envoi message ------------
[B]For Each cell In Sheets("MesDestinataires").Range("D2:D8").SpecialCells(xlCellTypeConstants)[/B]
If cell.Value Like "*@*" And cell.Offset(0, -3).Value = "x" Then
[COLOR=green]Prenom[/COLOR] = cell.Offset(0, -2).Value
DCarteVal = cell.Offset(0, -1).Value
AdresMail = cell.Value
[COLOR=blue]With ActiveSheet[/COLOR]
[COLOR=blue]'Set c = Range("A4:A11").Find(What:=[COLOR=green]Prenom[/COLOR], Lookat:=xlWhole)[/COLOR]
[COLOR=blue]'lig = c.Address[/COLOR]
[COLOR=blue]'lig = Range(lig).Row[/COLOR]
[COLOR=blue]j = 1[/COLOR]
[COLOR=blue]Do[/COLOR]
[COLOR=blue]j = j + 1[/COLOR]
[COLOR=blue]Loop Until Cells(10, j) <> "" Or j = 12[/COLOR]
[COLOR=blue]If j = 12 Then[/COLOR]
[COLOR=blue][COLOR=red]DebJournee[/COLOR] = "Aucune course à effectuer pour le moment"[/COLOR]
[COLOR=blue]Else[/COLOR]
[COLOR=blue][COLOR=red]DebJournee[/COLOR] = Cells(10, j)[/COLOR]
[COLOR=blue]End If[/COLOR]
[COLOR=blue]End With[/COLOR]
'Composer le message
Msg = "Bonjour " & Prenom & ","
Msg = Msg & vbCrLf & vbCrLf & "Tu trouveras ci-joint le planning du jour." & vbCrLf
Msg = Msg & "Ta journée débute ainsi : " & vbCrLf & vbCrLf & [COLOR=red]DebJournee[/COLOR] & vbCrLf & vbCrLf
Msg = Msg & "Cordialement Cibleo"
Set objMessage = New CDO.Message
'Set objMessage = CreateObject("CDO.Message")
With objMessage
.Subject = "Envoi Planning du jour à " & Prenom ' Sujet du mail
.From = "zozo[EMAIL="t@wanadoo.fr"]@wanadoo.fr[/EMAIL]"
.To = AdresMail
.TextBody = Msg
'.AddAttachment sCheminPDF & sNomPDF ' Fichier joint au mail
.Send '<<<<<<<<<<<<<<<Pour envoyer directement
End With
Set objMessage = Nothing
End If
[B]Next cell[/B]
End Sub