如何在 Outlook 中添加默认签名 [英] How to add default signature in Outlook

查看:47
本文介绍了如何在 Outlook 中添加默认签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Access 中编写一个 VBA 脚本,用于创建和自动填充几十封电子邮件.到目前为止,编码一直很顺利,但我是 Outlook 的新手.创建 mailitem 对象后,如何为电子邮件添加默认签名?

I am writing a VBA script in Access that creates and auto-populates a few dozen emails. It's been smooth coding so far, but I'm new to Outlook. After creating the mailitem object, how do I add the default signature to the email?

  1. 这将是创建新电子邮件时自动添加的默认签名.

  1. This would be the default signature that is automatically added when creating a new email.

理想情况下,我只想使用 ObjMail.GetDefaultSignature,但我找不到类似的东西.

Ideally, I'd like to just use ObjMail.GetDefaultSignature, but I can't find anything like it.

目前,我正在使用下面的功能(在互联网上的其他地方)并引用确切的路径 &htm 文件的文件名.但是这将被几个人使用,他们的默认 htm 签名文件可能有不同的名称.所以这可行,但并不理想:

Currently, I'm using the function below (found elsewhere on the internet) and referencing the exact path & filename of the htm file. But this will be used by several people and they may have a different name for their default htm signature file. So this works, but it's not ideal:

Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function

(使用 getboiler(SigString = "C:Users" & Environ("username") & "AppDataRoamingMicrosoftSignaturesMysig.txt") 调用)

编辑

感谢 JP(见评论),我意识到默认签名一开始会显示,但是当我使用 HTMLBody 向电子邮件添加表格时它消失了.所以我想我现在的问题是:如何显示默认签名并仍然显示 html 表?

Edit

Thanks to JP (see comments), I realize that the default signature is showing up at first, but it disappears when I use HTMLBody to add a table to the email. So I guess my question is now: How do I display the default signature and still display an html table?

Sub X()
    Dim OlApp As Outlook.Application
    Dim ObjMail As Outlook.MailItem

    Set OlApp = Outlook.Application
    Set ObjMail = OlApp.CreateItem(olMailItem)

    ObjMail.BodyFormat = olFormatHTML
    ObjMail.Subject = "Subject goes here"
    ObjMail.Recipients.Add "Email goes here"

    ObjMail.HTMLBody = ObjMail.Body & "HTML Table goes here"
    ObjMail.Display

End Sub

推荐答案

下面的代码将创建一个 Outlook 消息 &保留自动签名

The code below will create an outlook message & keep the auto signature

Dim OApp As Object, OMail As Object, signature As String

Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)

With OMail
    .Display
End With

signature = OMail.body

With OMail
    '.To = "someone@somedomain.com"
    '.Subject = "Type your email subject here"
    '.Attachments.Add
    .body = "Add body text here" & vbNewLine & signature
    '.Send
End With

Set OMail = Nothing
Set OApp = Nothing

这篇关于如何在 Outlook 中添加默认签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆