有效期限的电子邮件通知

时间:2015-05-28 19:54:50

标签: excel vba excel-vba

我希望在到期日之前通过电子邮件发送通知此代码在到期前30天发送电子邮件

    Sub reminder4()
 Dim lRow As Integer
 Dim i As Integer
 Dim toDate As Date
 Dim toList As String
 Dim eSubject As String
 Dim eBody As String
 Dim cList As String

 With Application
 .ScreenUpdating = False
 .EnableEvents = False
 .DisplayAlerts = False
    End With
    Sheets(2).Select
    lRow = Cells(Rows.Count, 4).End(xlUp).Row
    For i = 2 To lRow
     toDate = Replace(Cells(i, 3), ".", "/")

        If Left(Cells(i, 5), 4) <> "Mail" And toDate - Date <= 30 Then

     Set OutApp = CreateObject("Outlook.Application")
     Set OutMail = OutApp.CreateItem(0)
     Cells(i, 8) = "Mail Sent " & Date + Time

它在到期前30天发送电子邮件我想在到期时发送电子邮件。

1 个答案:

答案 0 :(得分:1)

替换此行:

If Left(Cells(i, 5), 4) <> "Mail" And toDate - Date <= 30 Then

使用:

If Left(Cells(i, 5), 4) <> "Mail" And toDate <= Date Then