Sub EnvoiParMailRELANCE1()
Dim ObjOutlook As New Outlook.Application
Dim oBjMail
Dim Nom(1 To 2000) As String
Dim Mail(1 To 2000) As String
Dim i As Integer
Dim FL As Range
Windows("Fichier executeur").Activate
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim xRg As Object
Dim MyDate as date
Application.ScreenUpdating = False
Set FL = Worksheets("Destinataires").[a1]
For i = 2 To 2000
Nom(i - 1) = FL.Cells(i, 1)
Mail(i - 1) = FL.Cells(i, 2)
If FL.Cells(i, 1) = "" Then
Exit For
End If
Next i
UserForm3.Show
Windows("Heures non imputées sans macros.xlsx").Activate
Set FL = Worksheets("CMS").[a1]
For i = 1 To 2000
If FL.Cells(i, 1) = "" Then
Exit For
End If
For j = 1 To 2000
If FL.Cells(i, 1) = Nom(j) Then
FL.Cells(i, 3).Value = "Mail envoyé"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = Mail(j)
.Subject = "Rappel heures non imputées"
.CC = "*****"
.Body = "Bonjour " & Nom(j) & vbNewLine & vbNewLine & _
"Selon le fichier extraction, vous avez au " & DateClicked & FL.Cells(i, 2).Value & " heures non imputées" & vbNewLine & vbNewLine & _
"En vous souhaitant bonne réception." & vbNewLine & vbNewLine & _
"Nouun"
.Importance = olImportanceHigh 'importance haute
.display
End With
Set OutMail = Nothing
Exit For
End If
If Nom(j) = "" Then
FL.Cells(i, 3).Value = "Pas de correspondance"
Exit For
End If
Next j
Next i
End Sub