【发布时间】:2020-06-21 07:26:38
【问题描述】:
我有一个 VBA 脚本,当在给定的工作表中按下 VBA 按钮时,它会生成并发送电子邮件。
脚本当前以相对较小的字体生成电子邮件。我想知道是否有办法将字体设置为 Calibri,并将文本设置为 11。
这是当前的 VBA 脚本:
Private Sub CommandButton1_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim strUser As String
Dim signature As String
Dim sTo As String
Dim sCC As String
'For To field
Set emailRng = Worksheets("Send Email").Range("D3:I6")
For Each cl In emailRng
sTo = sTo & ";" & cl.Value
Next
sTo = Mid(sTo, 2)
'For CC field
Set emailRngCC = Worksheets("Send Email").Range("D8:I11")
For Each cl In emailRngCC
sCC = sCC & ";" & cl.Value
Next
sCC = Mid(sCC, 2)
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Display
End With
signature = OutMail.HTMLBody
strbody = "<FONT SIZE = 3>Good Morning;<p>We have completed our main aliasing process for today. All assigned firms are complete. Please feel free to respond with any questions.<p>Thank you."
With OutMail
.SentOnBehalfOfName = ""
.To = sTo
.CC = sCC
.BCC = ""
.Subject = "Data Morning Alias Process - COMPLETE"
.HTMLBody = strbody & signature
.Display
End With
End Sub
我知道这部分代码:
strbody = "<FONT SIZE = 3.5>Good Morning;<p>We have completed our main aliasing
是与电子邮件正文文本大小相关的部分。但是设置为 3 太小,设置为 4 太大。所以我只是想知道是否有某种方法可以将字体设置为 11 号,并将文本格式化为 Calibri?
谢谢!
【问题讨论】:
-
如果是 HTML,它可能是这样的:
<p><font size="5" font face="calibri" color="blue">This is some text!</font></p>。我是从This site 那里得到的。虽然 ”。”似乎没有考虑到所以font size="5"=font size="5.1"=font size="5.9" -
也许这就是你想要的,来自Same site:
<p style="font-size:11px">This is some text!</p> -
感谢您的帮助,我查看了您发布的网站,它为我提供了在 Google 上搜索内容的基础。