跳至主要内容

如何根据Excel单元格中的日期快速发送电子邮件?

Author: Sun Last Modified: 2025-05-07

您是否尝试过根据Excel单元格中的日期发送电子邮件?例如,A列中有一系列日期,然后您想发送一封带有主题和正文的电子邮件给收件人(也可以抄送或密送给其他人),该如何处理呢?

使用VBA根据日期发送电子邮件


使用VBA根据日期发送电子邮件

要根据Excel中的日期发送电子邮件,您只能应用宏代码。

1. 启用包含数据和日期的工作表,并按 Alt + F11 键打开 Microsoft Visual Basic for Applications 窗口。

2. 单击 插入 > 模块,并将以下代码粘贴到空白脚本中。

Sub email()
'UpdatebyExtendoffice20170831
    Dim xRg As Range
    Dim xRgEach As Range
    Dim xAddress As String
    Dim xEmail_Subject, xEmail_Send_From, xEmail_Send_To, xEmail_Cc, xEmail_Bcc, xEmail_Body As String
    Dim xMail_Object, xMail_Single As Object
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Select a range:", "KuTools For Excel", xAddress, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    For Each xRgEach In xRg
        If xRgEach.Value = Date Then
            xEmail_Subject = Application.InputBox("Subject: ", "Kutools", , , , , , 2)
            xEmail_Send_From = Application.InputBox("Send from: ", "KuTools For Excel", , , , , , 2)
            xEmail_Send_To = Application.InputBox("Send to: ", "KuTools For Excel", , , , , , 2)
            If xEmail_Send_To = "" Then Exit Sub
            xEmail_Cc = Application.InputBox("CC: ", "KuTools For Excel", , , , , , 2)
            xEmail_Bcc = Application.InputBox("BCC: ", "KuTools For Excel", , , , , , 2)
            xEmail_Body = Application.InputBox("Message Body: ", "KuTools For Excel", , , , , , 2)
            Set xMail_Object = CreateObject("Outlook.Application")
            Set xMail_Single = xMail_Object.CreateItem(0)
            With xMail_Single
                .Subject = xEmail_Subject
                .To = xEmail_Send_To
                .cc = xEmail_Cc
                .BCC = xEmail_Bcc
                .Body = xEmail_Body
                .Send
            End With
        End If
    Next
End Sub

3. 单击 运行 按钮或按 F5 键执行代码,弹出一个对话框,提示您选择日期列表。参见截图:
Screenshot of selecting a date range for sending emails in Excel

4. 单击“确定”,继续指定电子邮件主题、发件人的电子邮件地址、收件人的电子邮件地址、抄送、密送和邮件正文。参见截图:

Screenshot of entering email subject for automated email Arrow right Screenshot of input box to specify the sender's email address Arrow right Screenshot of input box to specify the recipient's email address
        Arrow down
Screenshot of input box to enter CC address for email Arrow left Screenshot of input box to enter BCC address for email Arrow left Screenshot of input box to enter email message body

5. 单击 确定 > 确定 直到最后一个,然后电子邮件已发送。
Screenshot showing confirmation that the email has been sent

备注:发件人的电子邮件地址必须是Outlook中的默认账户。


在Excel中轻松创建邮件列表并发送电子邮件

借助 Kutools for Excel 的 创建邮件列表发送电子邮件 功能,您可以快速构建邮件列表并直接从Excel发送个性化电子邮件。您可以指定收件人、主题和附件,自定义邮件内容,并选择通过Outlook或其他SMTP服务器发送,方便进行电子邮件活动。

doc send email

Kutools for Excel - 通过超过300个必备工具,让Excel功能大幅提升。永久免费享受AI功能!立即获取

最佳办公效率工具

🤖 Kutools AI 助手:基于智能执行生成代码创建自定义公式分析数据并生成图表调用 Kutools 函数等功能,彻底改变数据分析方式…
热门功能查找、高亮或标记重复项 | 删除空行 | 合并不丢失数据的列或单元格 | 四舍五入 ...
高级 LOOKUP多条件 VLookup | 多值 VLookup | 多表查找 | 模糊查找 ....
高级下拉列表快速创建下拉列表 | 从属下拉列表 | 多选下拉列表 ....
列管理器添加指定数量的列 | 移动列 | 切换隐藏列的可见状态 | 比较区域和列 ...
精选功能网格聚焦 | 设计视图 | 增强编辑栏 | 工作簿与工作表管理器 | 资源库(自动文本) | 日期提取 | 合并数据 | 加密/解密单元格 | 按列表发送电子邮件 | 超级筛选 | 特殊筛选(筛选粗体/斜体/删除线...)...
排名前 15 的工具集12 种文本 工具添加文本删除特定字符等) | 50 多 种图表 类型甘特图等) | 40 多种实用 公式基于生日计算年龄等) | 19 种插入 工具插入二维码根据路径插入图片等) | 12 种转换 工具小写金额转大写汇率转换等) | 7 种合并与分割 工具高级合并行分割单元格等) | 还有更多...

使用 Kutools for Excel 提升您的 Excel 技能,体验前所未有的高效。 Kutools for Excel 提供超过 300 种高级功能来提高生产力并节省时间。 单击此处获取您最需要的功能...


Office Tab 将标签式界面引入 Office,让您的工作更加轻松

  • 在 Word、Excel、PowerPoint 中启用标签式编辑和阅读
  • 在同一窗口的新标签页中打开和创建多个文档,而不是在新窗口中进行操作。
  • 将您的生产力提升 50%,每天为您减少数百次鼠标点击!