Bonjour et bienvenue sur le forum,
Je vais essayer de donner un début de réponse compte tenu des informations transmises :
'CODE A PLACER DANS LE MODULE THISWORKBOOK
private sub workbook_open()
call routinemail(Date)
end sub
'CODES A PLACER DANS UN MODULE NORMAL
public oOutlook as Outlook.application
sub routinemail(Echeance as date)
Set oOutlook = New Outlook.Application
with activesheet
dl = .cells(.rows.count, 1).end(xlup).row
for i = 4 to dl
if .cells(i, "F").value <= Echeance then
Call envoimail(oOutlook, .cells(i, 2).value, "Relance", "Bonjour")
end if
next i
end with
set oOutlook = Nothing
end sub
sub envoimail(AppOutlook as Outlook.Application, destinataire$, sujet$, corps$, optional PJ$)
if AppOutlook is Nothing then set AppOutlook = New Outlook.application
with AppOutlook
set oMail = .CreateItem(olMailItem)
With oMail
.To = destinataire
.Subject = sujet
.Body = corps
.Attachments.Add PJ
.Display
'.Send
end with
set oMail = Nothing
End With
end sub
On teste sur la colonne F les dates inférieures à aujourd'hui et on envoie un mail en fonction des infos contenues dans les autres colonnes mais tout ça reste à définir correctement.
Cdlt,