Sub EnvoiMailCDO()
Dim mMessage As Object
Dim mConfig As Object
Dim mChps
Dim Derl&, Lig&
Derl = Feuil2.Range("B" & Rows.Count).End(xlUp).Row
For Lig = 6 To Derl
If Feuil2.Cells(Lig, 10) < Date Then
Feuil2.Cells(Lig, 12).Value = "Envoyé"
Set mConfig = CreateObject("CDO.Configuration")
mConfig.Load -1
Set mChps = mConfig.Fields
With mChps
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "..........."
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "..........."
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "True"
.Update
End With
Set mMessage = CreateObject("CDO.Message")
With mMessage
Set .Configuration = mConfig
.To = Feuil2.Cells(Lig, 11).Text
.From = "..........."
.Subject = "Courriel de relance"
.TextBody = "Bonjour " & Feuil2.Cells(Lig, 2).Text & "," & Chr(10) & Chr(10) _
& "Votre compte laisse apparaitre un retard de paiement concernant la facture " _
& Feuil2.Cells(Lig, 7).Text & "." & Chr(10) & "Cette facture concerne votre commande " _
& Feuil2.Cells(Lig, 8).Text & " du " & Feuil2.Cells(Lig, 9).Text _
& " qui aurait du être réglée avant le " & Feuil2.Cells(Lig, 10).Text & "." _
& Chr(10) & Chr(10) & "Cordialement" & Chr(10) & Chr(10) & "Le Gérant"
'.AddAttachment 'Chemin et nom complet du fichier à joindre
.Send
End With
Set mMessage = Nothing
Set mConfig = Nothing
Set mChps = Nothing
End If
Next Lig
End Sub