使用来自Excel表格的VBA发送电子邮件,并带有多个收件人 - 拉日期和附件

发布于 2025-02-09 16:46:52 字数 279 浏览 2 评论 0原文

我正在使用VBA代码从Excel表发送电子邮件:

我使用代码为C列中的每个电子邮件地址生成单独的电子邮件,并带有附加的文件。

我希望将代码添加到:

  1. 将日期从D列D到电子邮件正文。
    我已经为电子邮件的正文提供了我希望日期的代码。
    我如何按行获得每个电子邮件的日期。
  2. 如果列E中有链接,请将附加文件附加到电子邮件中。
    这将是代码中已经在代码中的一个。

Excel表中的每一行应使用C列中的电子邮件地址,D列中的日期和附件。

I am using VBA code to send emails from an Excel sheet:

I use code to generate a separate email for each email address in Column C with a file attached.

I am looking to add code to:

  1. Pull in the date from column D to the body of the email.
    I have put in the code for the body of the email where I want the date to go.
    How do I get the date for each email row by row.
  2. Attach an additional file to the email IF there is a link in column E.
    This would be in addition to the one already in the code.

Each row in the Excel sheet should generate a separate email using the email address in column C, date in column D and attachment in column E.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2025-02-16 16:46:52

假设其余代码有效,只需将块更新为:

With MItem
    .To = sourceWorksheet.Cells(RowIndex, 3).Value
    .Subject = "Subject Here"
    If Cells(RowIndex, 5) <> "" Then .Attachments.Add Cells(RowIndex, 5).Value
    If Cells(RowIndex, 6) <> "" Then .Attachments.Add Cells(RowIndex, 6).Value
    .HTMLBody = "<font face = ""Calibri(Body)"" font size=""3"" color=""black""><p>Good afternoon, </p>" & _
    "<p><strong>Please review the attached and return by " & Cells(RowIndex, 4) & ". </strong>  </p></font>" & .HTMLBody
     .Display
End With

assume that the rest of the code works, just update the with-block to:

With MItem
    .To = sourceWorksheet.Cells(RowIndex, 3).Value
    .Subject = "Subject Here"
    If Cells(RowIndex, 5) <> "" Then .Attachments.Add Cells(RowIndex, 5).Value
    If Cells(RowIndex, 6) <> "" Then .Attachments.Add Cells(RowIndex, 6).Value
    .HTMLBody = "<font face = ""Calibri(Body)"" font size=""3"" color=""black""><p>Good afternoon, </p>" & _
    "<p><strong>Please review the attached and return by " & Cells(RowIndex, 4) & ". </strong>  </p></font>" & .HTMLBody
     .Display
End With
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文