[英]How to send ActiveWorkbook.Path as link in email in excel VBA?
[英]vba excel send email using parent mailenvelope with html link in the introduction
使用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 = "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
編輯 -( http://vba-useful.blogspot.com/2014/01/send-html-email-with-embedded-images.html )
上面的鏈接詳細說明了如何制作超出范圍的jpg並將其通過電子郵件發送。
我發現一些非常相似的代碼似乎使用了稍微不同的方法。 也許會起作用。 似乎繞過了您嘗試的Mail.Envelope方法。 在羅恩·德布魯因(Ron de Bruin)的頁面上。 不幸的是,我無法在當前計算機上對其進行測試,因此希望對您有所幫助。
Sub Make_Outlook_Mail_With_File_Link()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Excel 2000-2013
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
If ActiveWorkbook.Path <> "" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<font size=""3"" face=""Calibri"">" & _
"Colleagues,<br><br>" & _
"I want to inform you that the next sales Order :<br><B>" & _
ActiveWorkbook.Name & "</B> is created.<br>" & _
"Click on this link to open the file : " & _
"<A HREF=""file://" & ActiveWorkbook.FullName & _
""">Link to the file</A>" & _
"<br><br>Regards," & _
"<br><br>Account Management</font>"
On Error Resume Next
With OutMail
.To = "ron@debruin.nl"
.CC = ""
.BCC = ""
.Subject = ActiveWorkbook.Name
.HTMLBody = strbody
.Display 'or use .Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Else
MsgBox "The ActiveWorkbook does not have a path, Save the file first."
End If
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.