excel - 添加超链接(Web)到 Outlook 电子邮件

标签 excel vba outlook

我在将超链接嵌入到某些文本(如this)时遇到问题.

我正在从 Excel 运行宏,该宏创建一个 Outlook 对象并对 c 列下的所有值重复。

以下内容不起作用,我该如何在此处嵌入链接?

.Body = "Click Here <https://www.google.com/>


下面的代码

Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range

Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")

On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
    If cell.Value Like "?*@?*.?*" And _
       LCase(Cells(cell.Row, "C").Value) = "yes" Then

        Set OutMail = OutApp.CreateItem(0)
        On Error Resume Next
        With OutMail

            .SentOnBehalfOfName = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7e0b0c1a1b1f0c1c11073e101b1b1a0d161b120e501d1113" rel="noreferrer noopener nofollow">[email protected]</a>"
            .to = cell.Value

            .Subject = "Subject" & Cells(cell.Row, "D").Value
            .Body = "Click Here <https://www.google.com/>"

             strLocation = "C:\Users\hahayouthought"
            .Attachments.Add (strLocation)

            .Display
        End With
        On Error GoTo 0
        Set OutMail = Nothing
    End If
Next cell

最佳答案

尝试使用.HTMLBody

示例

.HTMLBody = "<A href=https://www.google.com/> Click Here </A>"

MSDN HTMLBody Property

返回或设置表示指定项目的 HTML 正文的字符串。 HTMLBody 属性应该是 HTML 语法字符串。读/写。

MSDN .Body Property

返回或设置表示 Outlook 项目的明文正文的字符串。读/写。

关于excel - 添加超链接(Web)到 Outlook 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54101164/

相关文章:

xml - 更改自定义 Excel 功能区下拉列表的大小

excel - 选择 'save' 时如何使宏运行?

vba - DoCmd.DeleteObject acTable 与 acTable 有什么区别?掉落表

c# - 如何同步等待 'AuthenticationContext.AcquireTokenAsync()'?

vba - Outlook 等待几秒钟然后执行

sql-server - 如何将 SQL Server 存储过程结果返回到 Excel

通过 Jenkins 实现 Python Excel 自动化

java - Spring MVC,Excel文件下载,损坏文件

excel - 如果我有一个充满数据的大型工作表,是否可以使用 VBA 提取国家名称?

即使获得 Multi-Tenancy 应用程序的管理员同意,Azure AD 用户登录应用程序也会失败