【发布时间】:2020-06-03 13:42:21
【问题描述】:
我有一个表,其中包含从第 1 行到第 200 行和从 A 列到 T 列的数据,我需要 VBA 代码来向多个收件人发送电子邮件提醒。表中有日期,我使用了 if 条件并通过定义将返回 "YES" 的列到达。 YES 出现的地方应该发送相应的邮件(Column K)和相应的主题(Column C)
我能够创建定义和创建邮件并发送邮件。但无法使用 for 循环和 IF 条件来匹配条件并使用 .to = "" 发送到收件人列表
Sub Sendmail()
Dim ol As Outlook.Application
Dim olmail As Outlook.MailItem
Set ol = New Outlook.Application
For i = 1 To Sheet1.Cells(Rows.Count, 16).End(xlUp).Row
Set olmail = ol.CreateItem(olMailItem)
With olmail
.To = Sheet1.Cells(i, 16).Value
.Subject = Sheet1.Cells(i, 3).Value & Sheet1.Cells(i, 4).Value
.Body = Range("C2").Value
.Display
'.send
End With
Next
Set ol = Nothing
Set olmail = Nothing
End Sub
Outlook 应用程序正在打开,但没有邮件 ID
【问题讨论】: