ms-access - 更改通过 VBA 生成的 Outlook 电子邮件签名的字体大小
问题描述
我可以使签名加粗,但我不能改变大小。我也可以更改正文的大小,但不能更改签名。我需要更改签名的字体大小以匹配电子邮件中正文的字体大小。
Sub Email_Test()
'Exit function if user input incomplete:
If IsNull(Forms!frmCompMain!cboPayPrd) = True Then
MsgBox "Please provide the Pay Period parameter!", vbCritical
Exit Sub
End If
'-----------------------------------------
----'DECLARE AND SET VARIABLES
Dim myOutlok As Object
Dim myMailItm As Object
Dim Signature As String
Dim OtlApp As Object
Dim OtlNewMail As Object
Dim olMailItem As Object
Dim PayPrd As String
Set OtlApp = CreateObject("Outlook.Application")
Set OtlNewMail = OtlApp.CreateItem(0)
PayPrd = Forms!frmCompMain!cboPayPrd
'-----------------------------------------
-----'GET DEFAULT EMAIL SIGNATURE
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "*.htm")
Else:
Signature = ""
End If
Signature =
CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll
'-----------------------------------------
----'CREATE EMAIL
OtlNewMail.HTMLBody = Signature
With OtlNewMail
.to = ""
.CC = ""
.Subject = ""
.HTMLBody = "<font size='2'> Hello," & "<br />" & _
"<br />" & _
"" & "<br />" & _
"<br />" & _
"<b>Production Period:</b> " & DateSerial(Year(PayPrd)" & _
"<br />" & _
"<b> Pay Date:</b> " & DateSerial(Year(PayPrd), Month(PayPrd) + 1, 10) &
"<br />" & _
"<br />" & _
"Please let me know if you have any questions." & "<br />" & _
"<br />" & _
"<b>" & Signature & "</b>"
.display
'.Send
End With
'-----------------------------------------
----'CLEANUP
End Sub
解决方案
首先,您不能连接两个 HTML 字符串并期望返回一个有效的 HTML 字符串。两者必须合并。
其次,如果在 HTML 签名中明确设置了字体大小,那么将签名明确包装在具有指定字体大小的元素中的代码将无济于事。您需要使用 HTMLDocument 接口或 Word 对象模型来设置大小。
或者,最简单的解决方案是确保固定签名已经具有正确的字体。
推荐阅读
- python - 如何使用python控制手机?
- django - 如何排除 db Django 中的项目
- spring - BindingResult/Errors 没有在模型属性之后立即声明,但是没有问题,为什么?
- wpf - 如何使用用户控件中所有可用的列表视图宽度?
- c# - 对已知为原始类型的模板变量的值使用比较运算符
- javascript - 处理数组 Javascript 或 Jquery 问题的提示
- reactjs - 带有“npx create-react-app”的 IPFS-JS 导致 Webpack 错误
- reactjs - 使用 useContext 计算添加的次数 - React 和 Typescript
- c++ - 无法在 mingw64 上编译洞察调试器
- apostrophe-cms - 更改值的公共用户功能