使用outlook在电子邮件正文中添加html超链接似乎很简单,但我想发送电子表格中的一系列单元格和介绍中的文件链接,或者单击电子邮件中创建的图像并超链接到文件的简单方法。
我有下面的代码,但是如果我将介绍指定为HTMLintroduction,则strbody不允许它。
有什么想法吗?
Sub SendMail2()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
'Dim Sendrng As Range
Set Sendrng = Worksheets("Dashboard").Range("A1:Q34")
If ActiveWorkbook.Path <> "" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<font size=""3"" face=""Calibri"">" & _
ActiveWorkbook.Name & "</B> is created.<br>" & _
"Click on this link to open the file : " & _
"<A HREF=""file://" & ActiveWorkbook.FullName & _
""">Link to the file</A>"
With Sendrng
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
.Introduction = strbody
On Error Resume Next
With ActiveSheet.MailEnvelope.Item
.To = "[email protected]"
.CC = ""
.BCC = ""
.Subject = ActiveWorkbook.Name
'.HTMLBody = strbody
.Display 'or use .Send
End With
End With
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Else
MsgBox "Email not sent."
End If
End Sub
字符串
2条答案
按热度按时间djp7away1#
编辑-(http://vba-useful.blogspot.com/2014/01/send-html-email-with-embedded-images.html)
上面的链接详细说明了如何制作jpg的范围,并发送在电子邮件中。
我发现了一些非常相似的代码,似乎使用了稍微不同的方法。也许它会工作。它似乎绕过了您正在尝试的Mail.Envelope方法。从Ron de Bruin's页面。不幸的是,我无法在当前机器上测试它,所以我希望它能有所帮助。
字符串
kknvjkwl2#
这应该工作。我已经测试了它与网站链接,而不是与您的文件结构,但它应该工作。
字符串
:)