使用VBA excel在特定日期发送带有Outlook的电子邮件

时间:2015-05-27 15:51:10

标签: excel vba excel-vba outlook

我正在使用excel VBA工作发送Outlook电子邮件的宏。我已经迈出了向不同收件人发送电子邮件的第一步。我的代码:

Sub SetRecipients()
Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String

Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)

Set rngeAddresses = ActiveSheet.Range("A3:A13")
For Each rngeCell In rngeAddresses.Cells
strRecipients = strRecipients & ";" & rngeCell.Value
Next

aEmail.Importance = 2

aEmail.Subject = "Indicator activity warning ( TestMailSend )"

aEmail.Body = "Hi"

'aEmail.ATTACHMENTS.Add ActiveWorkbook.Book2.xlsx

aEmail.To = strRecipients

aEmail.Send

End Sub

我的目标:是能够设置多个不同日期,以便自动发送此电子邮件。

问题:我不确定这是如何运作的

1 个答案:

答案 0 :(得分:0)

您似乎对Outlook项目(MailItem)的DeferredDeliveryTime属性感兴趣。它允许设置DateTime,指示邮件传递的日期和时间。

您可能会发现How to automate Outlook from another program文章很有帮助。