Mail automatique

bonjour à tous,

nouveau sur le forum je viens vers vous car j'ai rencontré un problème. ci dessous, mon code pour envoyer un mail automatique, cependant la fonction ne fonctionne pas en automatique mais si je l'actionne via un module ça fonctionne. auriez vous une idée?

Private Sub mail()

Dim outapp As Object

Dim outmail As Object

Dim strbody As String

With Worksheets("tableau de bord")

derlig = Range("k" & Rows.Count).End(xlUp).Row

For L = 1 To derlig

strbody = ""

If Range("k" & L) = "à commander" Then

Set outapp = CreateObject("outlook.application")

Set outmail = outapp.CreateItem(0)

strbody = .Range("f" & L) & "et" & .Range("b" & L) & " a commmander"

With outmail

.To = ""

.CC = ""

.BCC = ""

.Subject = "a commander"

.Body = strbody

.Send

End With

.Range("k" & L) = "à commander" & " ok"

On Error GoTo 0

End If

Set outmail = Nothing

Set outapp = Nothing

Next L

End With

End Sub

Rechercher des sujets similaires à "mail automatique"