【发布时间】:2015-02-20 17:37:30
【问题描述】:
使用 Outlook 将 html 超链接添加到电子邮件正文似乎很简单。 但是,我想在电子表格中发送一系列单元格,并在介绍中发送指向该文件的链接。或者点击电子邮件中创建的图像并链接到文件的简单方法。
我有以下代码,但是 strbody 如果我将介绍指定为 HTMLintroduction,则不允许。
有什么想法吗?
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 = "ac@uk.com"
.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
【问题讨论】: