如何使用HTMLBody在电子邮件上添加VBA签名? [英] How to add VBA Signature on Email with HTMLBody?

查看:469
本文介绍了如何使用HTMLBody在电子邮件上添加VBA签名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从如何在Outlook中添加默认签名.但是,在设置签名变量的地方,我总是收到错误消息应用程序定义的错误或对象定义的错误".如何解决此错误?

I got the following from How to add default signature in Outlook. However, I keep getting an error "Application-defined or object-defined error" where the signature variable is set. How can I fix this error?

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

我知道我可以从C:\ Users ... \ Signatures \文件夹中获得签名.但是,在工作中,我们所有人都使用虚拟桌面,并且权限有点笨拙.

I know I could get the signature from the C:\Users...\Signatures\ folder. However at work, we all use virtual desktops and the permissions there are a tad janky.

推荐答案

您的签名必须声明为变体.

Your signature has to be declared as a variant.

Dim OApp As Object
Dim OMail As Object
Dim Signature As Variant

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

On Error Resume Next
With OMail
    'Capture signature block.
    .Display
    Signature = .HTMLBody
    '.To = Recipients
    '.CC = CarbonCopy
    .Subject = "Subject"
    .HTMLBody = "<p>Add Body Here.</p>" & Signature
    .Display
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

这篇关于如何使用HTMLBody在电子邮件上添加VBA签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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