我傾向於做的是我有一個Excel表和工作人員名單,我想發送一個Excel表單提醒。我試圖用DefferdDeliverytime選項發送電子郵件,將電子郵件停放在發件箱中,並在稍後發送。使用此代碼,我可以發送消息,但是我不知道如何執行的操作是,根據Excel表添加代碼以發送特定的發送時間併發送電子郵件。任何人都可以添加一個代碼讓我工作。VBA發送不同時間的大量郵件
Sub Mail_To_Friends()
'Below Loop can be changed to While Loop or increase the limit (10) if your list has more than 10 mail ids
Dim SendTo As String
Dim ToMSg As String
Dim DueDate As String
Dim AwardN As String
Dim SendTime As String
For i = 2 To 10
SendTo = ThisWorkbook.Sheets(1).Cells(i, 22)
If SendTo <> "" Then
ToMSg = ThisWorkbook.Sheets(1).Cells(i, 15)
DueDate = ThisWorkbook.Sheets(1).Cells(i, 14)
AwardN = ThisWorkbook.Sheets(1).Cells(i, 1)
SendTime = ThisWorkbook.Sheets(1).Cells(i, 22)
Send_Mail SendTo, ToMSg, DueDate, AwardN, SendTime
End If
Next i
End Sub
Sub Send_Mail(SendTo As String, ToMSg As String, DueDate As String, AwardN As String, SendTime As String)
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.To = SendTo
.CC = ""
.BCC = ""
.Subject = "draft report is due"
.Body = "Dear " & ToMSg & vbNewLine & vbNewLine & "The following report is due to member on " & DueDate & vbNewLine & vbNewLine & "Award Name: " & AwardN
.Display 'or just put .Send to directly send the mail instead of display
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
您必須更準確地描述您遇到的問題。 – byako
我已更新我的問題 –