将Hyperlink放在VBA代码中以自动发送电子邮件

时间:2017-10-06 17:09:35

标签: excel excel-vba hyperlink vba

我创建了一个自动发送电子邮件的VBA代码。在那封电子邮件中,我希望有一个链接到我上传文件的网页的超链接。

我遇到的麻烦是将HTML Hyperlink标签放在VBA代码中。

查看我的代码:

msgbody = "Hi Everyone" & "<br> <br>" _
& "I have attached the excel file to this afternoon's Open Order Report above, as well as provided the link below:" & "<br> <br>" _
& "Please reach out if you have any more questions or concerns" & "<br>"
& "<a href= & "www.google.com">" & "link" </a>"

With objemail
    .to = "spall@.its.jnj.com"
    .cc = ""
    .Subject = "test"
    .htmlbody = msgbody
    .display
End With

End Sub

1 个答案:

答案 0 :(得分:2)

替换它:

& "<a href= & "www.google.com">" & "link" </a>"

用这个

& "<a href=" & """" & "www.google.com" & """" & ">" & "link" </a>"