1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Sub sendMail()
Dim iMsg As Object, iConf As Object, Flds As Object
Dim destinataire As String
Dim y As Integer
Dim x As Integer
Dim liste_client As String
Set iMsg = CreateObject("cdo.message")
Set iConf = CreateObject("cdo.configuration")
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "serveur"
.Update
End With
x = 2
y = 2
destinataire = Cells(1, y)
While (Not (IsEmpty(Cells(1, y))))
liste_client = ""
x = 2
While (Not (IsEmpty(Cells(x, y))))
liste_client = liste_client + " " + Cells(x, y)
x = x + 1
Wend
If (Not (IsEmpty(liste_client))) Then
With iMsg
Set .Configuration = iConf
.To = "mon adresse"
.From = destinataire
.Subject = "Données manquantes"
.HTMLBody = "Bonjour, voici les clients : " + liste_client
.Send
End With
End If
y = y + 1
destinataire = Cells(1, y)
Wend
End Sub |
Partager