Add the default outlook signature in the email generated

前端 未结 11 457
甜味超标
甜味超标 2020-12-08 07:11

I am using the Microsoft.Office.Interop.Outlook.Application to generate an email and display it on the screen before the user can send it. The application is a

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 07:58

    I've found a very easy way to attach the default outlook signature (including images). The trick is to retrieve the body message after calling the GetInspector and concat your message to that.

    Imports Microsoft.Office.Interop
    
    Dim fdMail As Outlook.MAPIFolder
    Dim oMsg As Outlook._MailItem
    oMsg = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
    Dim olAccounts As Outlook.Accounts
    oMsg.SendUsingAccount = olAccounts.Item(1)
    oMsg.Subject = "XXX"
    oMsg.To = "xxx@xxx.com"
    Dim myInspector As Outlook.Inspector = oMsg.GetInspector
    Dim text As String
    text = "mail text" & oMsg.HTMLBody
    oMsg.HTMLBody = text
    oMsg.Send()
    

提交回复
热议问题