我正在嘗試將Excel數據添加到Outlook電子郵件中。將簽名添加到電子郵件的末尾
這是Outlook電子郵件編輯器中輸出的說明。我試圖添加的img應該在Excel內容後面添加。
我試過各種方法來添加一個腳註的圖像。
我試着添加<img>
標籤來附加它作爲HTML附件,但它沒有任何間距的連接。
使用這兩條線最初嘗試
.Attachments.Add "C:\Users\Sumit Jain\Pictures\11\city.jpg", olByValue, 0
.HTMLBody = .HTMLBody & "<img src='cid:city.jpg'><br>"
然後我試圖在Outlook使默認的簽名。
代碼
.HTMLBody = "<HTML><body><body></HTML>" & .HTMLBody
附加在上面Outlook的默認簽名,然後將Excel內容之後。
參考頁我使用的邏輯從Link
下面是代碼
Private Sub CommandButton9_Click()
On Error GoTo ERRORMSG
Dim OutApp As Object
Dim OutMail As Object
Dim olInsp As Object
Dim wdDoc As Object
Dim oRng As Object
Set otlApp = CreateObject("Outlook.Application")
Set olMail = otlApp.CreateItem(olMailItem)
Set Doc = olMail.GetInspector.WordEditor
Set mainWB = ActiveWorkbook
mainWB.Sheets("Mail").Range("m8").Value = ComboBox4.Value
mainWB.Sheets("Mail").Range("n8").Value = TextBox40.Value
mainWB.Sheets("Mail").Range("q8").Value = ComboBox5.Value
mainWB.Sheets("Mail").Range("r8").Value = ComboBox6.Value
mainWB.Sheets("Mail").Range("s8").Value = ComboBox7.Value
mainWB.Sheets("Mail").Range("t8").Value = TextBox44.Value
On Error Resume Next
Set OutApp = GetObject(, "Outlook.Application")
If Err <> 0 Then Set OutApp = CreateObject("Outlook.Application")
On Error GoTo 0
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = mainWB.Sheets("Email").Range("A3").Value
.cc = mainWB.Sheets("Mail").Range("L12").Value
.Subject = mainWB.Sheets("Mail").Range("O15").Value
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range
'force html format
.HTMLBody = "<HTML><body><body></HTML>" & .HTMLBody
.Display
'--- start with 6 CrLf's, so we can place each table
' above all but the last used...
oRng.InsertAfter vbCrLf & vbCrLf
'--- now reselect the entire document, collapse our cursor to the end
' and back up one character (so that the table inserts before the SIXTH CrLf)
Set oRng = wdDoc.Range
oRng.collapse 0
oRng.Move 1, -1
Range("K3:T10").Select
Selection.Copy
oRng.Paste
'--- finally move the cursor all the way to the end and paste the
' second table BELOW the SIXTH CrLf
Set oRng = wdDoc.Range
oRng.collapse 0
Range("K38:T46").Select
Selection.Copy
oRng.Paste
End With
Exit Sub
End Sub
應該是'.Attachments.Add「C:\ Use rs \ Sumit Jain \ Pictures \ 11 \ city.jpg「,olByValue,0' '.HTMLBody =」
「' – 0m3r試過上面提到的。這會在開頭追加圖片,然後是excel內容。而我試圖以相反的方式得到它 –
你能舉一個例子嗎? – 0m3r