XL 2019 peut on créer des alertes par email d'un fichier excel ?

soso75017

XLDnaute Nouveau
Bonjour,

Je ne sais pas faire une macro, j'ai besoin de recevoir un mail quand la date d'échéance arrive à terme.
J'ai un liste de salarié en colonne B, des dates de validité de carte pro en colonne I, date d'échéance de carte pro en colonne I, et date d'échéance du MAC en colonne O.

Je souhaite savoir s'il est possible de recevoir une alerte par mail , quand la date de validité de la carte pro arrive à échéance (colonne I), quand la date d'échéance arrive à échéance pour la carte pro (colonne J) et idem pour la date de l'échéance du MAC (colonne O), avec le nom du salarié (colonne B).


Merci par avance
Capture d’écran 2022-08-16 112609.png
 

Pièces jointes

  • CARTES PROS-PA-FORMATIONS.xlsx
    43.1 KB · Affichages: 3
Dernière édition:

Phil69970

XLDnaute Barbatruc
Bonjour @soso75017

Edit : Bonjour @Hasco


Quelques remarques :
1) Ecrire en majuscule c'est crier et j'aime pas quand on me crie dessus o_O
2) Une image reste une image et un fichier est un fichier ==> essaye de faire une macro sur une image 🤣 🤔
3) Il y a des centaines d'exemples de demande de mail avec échéance sur le site ==> tu peux essayer de t'en inspirer

Bonne lecture

@Phil69970
 

soso75017

XLDnaute Nouveau
J'ai mis ces codes mais cela ne fonctionne

Public Sub CheckAndSendMail()

'Updated by Extendoffice 2018/11/22

Dim xRgDate As Range

Dim xRgSend As Range

Dim xRgText As Range

Dim xRgDone As Range

Dim xOutApp As Object

Dim xMailItem As Object

Dim xLastRow As Long

Dim vbCrLf As String

Dim xMailBody As String

Dim xRgDateVal As String

Dim xRgSendVal As String

Dim xMailSubject As String

Dim i As Long

On Error Resume Next

Set xRgDate = Application.InputBox("Please select the due date column:", "KuTools For Excel", , , , , , 8)

If xRgDate Is Nothing Then Exit Sub

Set xRgSend = Application.InputBox("Please select the recipients?email column:", "KuTools For Excel", , , , , , 8)

If xRgSend Is Nothing Then Exit Sub

Set xRgText = Application.InputBox("Select the column with reminded content in your email:", "KuTools For Excel", , , , , , 8)

If xRgText Is Nothing Then Exit Sub

xLastRow = xRgDate.Rows.Count

Set xRgDate = xRgDate(1)

Set xRgSend = xRgSend(1)

Set xRgText = xRgText(1)

Set xOutApp = CreateObject("Outlook.Application")

For i = 1 To xLastRow

xRgDateVal = ""

xRgDateVal = xRgDate.Offset(i - 1).Value

If xRgDateVal <> "" Then

If CDate(xRgDateVal) - Date <= 7 And CDate(xRgDateVal) - Date > 0 Then

xRgSendVal = xRgSend.Offset(i - 1).Value

xMailSubject = xRgText.Offset(i - 1).Value & " on " & xRgDateVal

vbCrLf = "<br><br>"

xMailBody = "<HTML><BODY>"

xMailBody = xMailBody & "Dear " & xRgSendVal & vbCrLf

xMailBody = xMailBody & "Text : " & xRgText.Offset(i - 1).Value & vbCrLf

xMailBody = xMailBody & "</BODY></HTML>"

Set xMailItem = xOutApp.CreateItem(0)

With xMailItem

.Subject = xMailSubject

.To = xRgSendVal

.HTMLBody = xMailBody

.Display

'.Send

End With

Set xMailItem = Nothing

End If

End If

Next

Set xOutApp = Nothing

End Sub
 

Discussions similaires

Réponses
5
Affichages
180
Réponses
2
Affichages
233
Réponses
2
Affichages
248

Membres actuellement en ligne

Statistiques des forums

Discussions
312 196
Messages
2 086 084
Membres
103 116
dernier inscrit
kutobi87