将 Outlook 签名添加到新邮件项目

Posted

技术标签:

【中文标题】将 Outlook 签名添加到新邮件项目【英文标题】:Add Outlook signature to new Mail item 【发布时间】:2016-09-16 14:48:13 【问题描述】:

我从代码中列出的 2 个单元格创建了一封新电子邮件。新电子邮件没有附加我的电子邮件签名。

我已经尝试解决它,但我有点挣扎。它是从htmlBody 引用中提取的吗?

Sub SendHTMLEmail(from_sender As String, what_address1 As String, cc_sender As String, subject_line1 As String, mail_body1 As String)

      Dim olapp As Outlook.Application
      Dim olmail As Outlook.MailItem

      Set olapp = CreateObject("Outlook.Application")
      Set olmail = olapp.CreateItem(olMailItem)

      olmail.SentOnBehalfOfName = from_sender
      olmail.To = what_address1
      olmail.CC = cc_sender
      olmail.Subject = subject_line1
      olmail.HTMLBody = mail_body1
      olmail.Display

End Sub

Sub SendHoldingEmail()

      Dim EmailWordings As Excel.Worksheet
      Dim row_number As Long
      Dim from_sender As String, cc_sender As String, Email_Subject As String, full_name As String, mail_body_message As String


      Set EmailWordings = ThisWorkbook.Sheets("EmailWordings")

      row_number = 1

      Do
         DoEvents

         row_number = row_number + 1

         from_sender = "blah@hotmail.com"
         cc_sender = "blah@hotmail.com"
         mail_body_message = EmailWordings.Range("D3")
         Email_Subject = EmailWordings.Range("B3")

         Call SendHTMLEmail(from_sender, "", cc_sender, Email_Subject, mail_body_message)

      Loop Until row_number = 2


  End Sub

【问题讨论】:

【参考方案1】:

设置 HTMLbody 时,请确保将现有 HTMLbody 附加到它的末尾。包含现有签名。

Sub SendEmail()

    Dim OutlookApplication As Object, OutlookMail As Object

    Set OutlookApplication = CreateObject("Outlook.Application")
    Set OutlookMail = OutlookApplication.CreateItem(0)
    With OutlookMail
        .GetInspector
        .HTMLBody = "Email Content" & .HTMLBody
        .Display
    End With

End Sub

【讨论】:

以上是关于将 Outlook 签名添加到新邮件项目的主要内容,如果未能解决你的问题,请参考以下文章

通过 Outlook 中的宏写入电子邮件添加默认电子邮件签名

AD 脚本kixtart运用之六(outlook邮件批量生成签名)

NodeJS Mail listener2 正在将电子邮件签名图像作为附件下载到 Outlook 中,如何阻止它?

如何在outlook web app的签名档

备份和导入Outlook 2016 电子邮件签名

如何将电脑outlook里面的邮件转移到另外一台电脑