我想设置发送时间以发送多封电子邮件。我决定在Excel列中输入日期和时间(例如在M列中)。
我编写了可以保存电子邮件草稿的代码。我检查完电子邮件后。我会寄出。但是我可以使用Vba
设置投放时间吗?
完成检查后,按发送按钮。电子邮件将在我在M列中设置的特定时间发送。这是我的代码
Sub preview()
On Error GoTo Endnow
Application.ScreenUpdating = False
Dim WordDoc As Object
Dim WordFile As String
'WordFile = Application.GetOpenFilename(Title:="Select MS Word file", MultiSelect:=False)
WordFile = Cells(1, 1).Value
Set WordDoc = GetObject(WordFile)
Dim OutApp As Object, OutMail As Object, OutWordEditor As Object
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
Dim cell As Range
For Each cell In Columns("C").Cells.SpecialCells(xlCellTypeConstants)
If LCase(Cells(cell.Row, "B").Value) = "y" Then
Set OutMail = OutApp.CreateItem(0)
Set OutWordEditor = OutMail.GetInspector.WordEditor
On Error Resume Next
With OutMail
.To = cell.Value
.cc = cell.Offset(, 2)
.Subject = Cells(cell.Row, "G").Value
.Body = Cells(cell.Row, "F").Value
Set editor = .GetInspector.WordEditor
editor.Content.Paste
Set WordDoc = GetObject(WordFile)
WordDoc.Content.Copy
OutWordEditor.Content.Paste
OutWordEditor.Range(0).InsertBefore (Cells(cell.Row, "F").Value & vbCrLf & vbCrLf)
WordDoc.Close
.Attachments.Add (Cells(cell.Row, "H").Text)
.Attachments.Add (Cells(cell.Row, "I").Text)
'.Display
.Save
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
Endnow:
End Sub
那么如何使用vba设置投放时间?因为每个收件人的交货时间都不同。