gpt4 book ai didi

excel - 在 VBA 中更改 HTML 电子邮件正文字体类型和大小

转载 作者:行者123 更新时间:2023-12-01 19:24:12 75 4
gpt4 key购买 nike

我有一个 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?

谢谢!

最佳答案

我做了一些研究并能够编写以下代码:

strbody = "<BODY style=font-size:11pt;font-family:Calibri>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.</BODY>"

显然是通过设置 "font-size=11pt"而不是设置字体大小<font size=5> ,它允许您像通常在文本编辑器中一样选择特定的字体大小,而不是像我的代码最初那样选择 1-7 之间的值。

这个 link 来自 simple Man 给了我一些很好的信息。

关于excel - 在 VBA 中更改 HTML 电子邮件正文字体类型和大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22200910/

75 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com