【发布时间】:2015-08-10 16:53:58
【问题描述】:
您好,我想将电子邮件发送到选中的地址 我有:
- 复选框
- 列名
-
列电子邮件
Sub reminder1() Dim lRow As Integer Dim i As Integer Dim toList As String Dim eSubject As String Dim eBody As String With Application .ScreenUpdating = False .EnableEvents = False .DisplayAlerts = False End With Sheets(1).Select lRow = Cells(Rows.Count, 4).End(xlUp).Row For i = 2 To lRow If Sheets("Sheet1").CheckBox1.Value = True Then Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) Cells(i, 5) = "Mail Sent " & Date + Time Cells(i, 5).Font.Bold = True toList = Cells(i, 3) eSubject = "Your " eBody = "Good Day" On Error Resume Next With OutMail .To = toList .CC = "" .BCC = "" .Subject = eSubject .BodyFormat = olFormatHTML .Display .HTMLBody = eBody & vbCrLf & .HTMLBody '.Send End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End If Next i ActiveWorkbook.Save With Application .ScreenUpdating = True .EnableEvents = True .DisplayAlerts = True End With End Sub
问题是,如果我选中第一个,它会向所有人发送电子邮件,如果未选中,即使选中其他复选框也不会发送电子邮件
【问题讨论】:
-
您的代码只查看一个复选框 (Checkbox1)。