【问题标题】:Include Excel Range value in htmlbody of mail在邮件的 htmlbody 中包含 Excel 范围值
【发布时间】:2018-11-04 08:15:35
【问题描述】:

我正在尝试在 .htmlbody 中包含 Range("F2").Value。

signature = opemail.htmlbody '

With opemail
    .to = "s"
    .Subject = ActiveCell.Value & " - " & "Daily report - " & Date - 1
    .htmlbody = "<p style=""font:11pt Calibri;""> **Range("F2").Value** <br> more text </p>" & signature

单元格“F2”有一个随时间变化的文本(早上好 12 下午好)。

我的英语很基础。

【问题讨论】:

    标签: vba excel outlook


    【解决方案1】:

    您可以使用问题中所述的单元格引用,您只需要使用 & 符号来链接字符串:

    .htmlbody = "<p style=""font:11pt Calibri;"">" & Range("F2").Value & "<br> more text </p>"
    

    或者您可以在 VBA 中执行此操作而不使用单元格引用:

            Dim CurTime
                If Hour(Now) < 12 Then
                        CurTime = "Good Morning"
                    Else
                        CurTime = "Good Afternoon"
                End If
    
            signature = opemail.htmlbody
    
            With opemail
                .to = "s"
                .Subject = ActiveCell.Value & " - " & "Daily report - " & Date - 1
                .htmlbody = "<p style=""font:11pt Calibri;"">" & CurTime & "<br> more text </p>"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-12
      • 1970-01-01
      • 1970-01-01
      • 2021-02-17
      相关资源
      最近更新 更多