将签名添加到电子邮件的末尾

问题描述:

我正在尝试将Excel数据添加到Outlook电子邮件中。将签名添加到电子邮件的末尾

这是Outlook电子邮件编辑器中输出的说明。我试图添加的img应该在Excel内容后面添加。 This is a illustration of how the output in a outlook email editor. The img I'm trying to add should be add at the end, after the excel content

我试过各种方法来添加一个脚注的图像。

我试着添加<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 
+0

应该是'.Attachments.Add“C:\ Use rs \ Sumit Jain \ Pictures \ 11 \ city.jpg“,olByValue,0' '.HTMLBody =”

“' – 0m3r
+0

试过上面提到的。这会在开头追加图片,然后是excel内容。而我试图以相反的方式得到它 –

+0

你能举一个例子吗? – 0m3r

尝试在你的代码如下....

您需要添加Mysig.htm的名称您的签名

SigString = Environ("appdata") & "\Microsoft\Signatures\" & UOutLookSign & ".htm" 

If Dir(SigString) <> "" Then 

    Signature = GetBoiler(SigString) 

Else 

    Signature = "" 

End If 
+0

来源提供完整的信息。 http://www.rondebruin.nl/win/s1/outlook/signature.htm – niton