Email verschicken wenn Datum abgelaufen
25.01.2021 17:27:29
Tina
ich habe in einem alten Thread die (fast) perfekte Lösung gefunden. Mir fehlt nur eine Kleinigkeit: Ich möchte, dass die Mail nur einmal gesendet wird, wenn mehrere Zellen das abgefragte Kriterium erfüllen.
Danke schonmal für die Hilfe - ich bin sicher, sie kommt! :-)
Tina
----------------------
Private Sub Workbook_Open()
Dim ws As Worksheet
Dim i As Integer
For Each ws In ThisWorkbook.Worksheets
With ws
For i = 4 To .Cells(Rows.Count, 8).End(xlUp).Row
If .Cells(1, 9).Value > .Cells(i, 8).Value Then
If .Cells(i, 15).Value "" Then
' Mailversand
Dim MyOutApp As Object
Dim MyMessage As Object
Set MyOutApp = CreateObject("Outlook.application")
Set MyMessage = MyOutApp.createitem(0)
With MyMessage
.To = ws.Cells(i, 15).Value
.Subject = "Titel"
.Body = "Nachricht"
.Display ' Mail anzeigen ohne automatischen Versand
'.Send ' Mail automatisch senden ohne vorherige Anzeige
End With
Set MyMessage = Nothing
Set MyOutApp = Nothing
' Mailversand ENDE
Else
MsgBox "Fehlende Email-Adresse in Tabelle: " & ws.Name & " Zelle: " & ws.Cells(i, _
_
15).Address
End If
End If
Next i
End With
Next ws
End Sub