使用Excel VBA在Outlook邮件中的粘贴正文之后插入签名

时间:2018-12-19 07:40:17

标签: excel vba outlook outlook-2010

我正在使用以下代码从Excel创建电子邮件:

Sub TEST()

Dim outlook As Object
Dim newEmail As Object

Set outlook = CreateObject("Outlook.Application")
Set newEmail = outlook.CreateItem(0)

With newEmail
    .To = Sheet1.Range("L2").Text
    .Subject = Sheet1.Range("E1").Text

    ' .Body = "" & vbNewLine & signature
    .Display

    Dim xInspect As Object
    Dim pageEditor As Object

    Set xInspect = newEmail.GetInspector
    Set pageEditor = xInspect.WordEditor

    Sheet1.Range("B4:L37").Copy

    pageEditor.Application.Selection.Start = Len(.Body)
    pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
    pageEditor.Application.Selection.Paste

    Set pageEditor = Nothing
    Set xInspect = Nothing
End With

Set newEmail = Nothing
Set outlook = Nothing

End Sub

我的签名将自动出现在文本正文之前。

是否可以在以后插入我的签名?

1 个答案:

答案 0 :(得分:0)

在Excel中的新工作表中创建签名,并将其添加到电子邮件正文中,就像您对正文内容所做的一样,这最好是自定义签名。

否则,您可以使用以下想法:

if  Not (Account  Is  Nothing)  Then
   set Signature = Account.NewMessageSignature
   if  Not (Signature  Is  Nothing)  Then
    Signature.ApplyTo Msg,  false   'apply at the bottom
   End If
End If

来自此帖子: How to add default signature in Outlook