VBA更改邮件字体

发布于 2025-02-09 13:20:22 字数 715 浏览 4 评论 0原文

我创建了一个VBA代码,但是邮件的字体和大小不正确。我想要Calibri 11,但第一行的Calibri 10(Hello),其余的Verdana 10。如何进行?

Sub mail_outlook()

Dim OutApp As Object 
Dim OutMail As Object 

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

With OutMail 
    .SentOnBehalfOfName = "xxxxxxxxxxxx"
    .Display 

    .To = "xxxxxxxxxxxxxxxxxx"
    
    .HTMLBody = "Hello, " & "<br>" & "<br>" & "Please find in attachment the Report." & "<br>" & "We remain available should you have any questions." & .HTMLBody
    .CC = "xxxxxxxxxxxxxxx"
    .BCC = "" 
    .Subject = "Report"

    
End With 

Set OutMail = Nothing 
Set OutApp = Nothing


End Sub  

I created a vba code but the font and the size of the mail are incorrect. I would like Calibri 11 but it's Calibri 10 for the first line (Hello) and Verdana 10 for the rest. How to proceed?

Sub mail_outlook()

Dim OutApp As Object 
Dim OutMail As Object 

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

With OutMail 
    .SentOnBehalfOfName = "xxxxxxxxxxxx"
    .Display 

    .To = "xxxxxxxxxxxxxxxxxx"
    
    .HTMLBody = "Hello, " & "<br>" & "<br>" & "Please find in attachment the Report." & "<br>" & "We remain available should you have any questions." & .HTMLBody
    .CC = "xxxxxxxxxxxxxxx"
    .BCC = "" 
    .Subject = "Report"

    
End With 

Set OutMail = Nothing 
Set OutApp = Nothing


End Sub  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是偏爱你 2025-02-16 13:20:22

You can specify the font size in the HTML:

"<font style=""font-family: Calibri; font-size: 11pt;""> your content goes here</font>"

See Change HTML电子邮件主体字体类型和VBA中的大小有关更多信息。

另外,您可以使用“对象模型”一词来编程执行此操作。 wordeditor Inspector类的wordeditor 代表消息主体的单词对象模型的文档类实例。参见第17章:与物体有关更多信息。例如,在Word中,您可以使用以下属性调用序列:

Selection.WholeStory
Selection.Font.Size = 12
Selection.Font.Name = "Georgia"

You can specify the font size in the HTML:

"<font style=""font-family: Calibri; font-size: 11pt;""> your content goes here</font>"

See Change HTML email body font type and size in VBA for more information.

Also you may use the Word object model for doing that programmatically. The WordEditor of the Inspector class returns an instance of the Document class from the Word object model which represents the message body. See Chapter 17: Working with Item Bodies for more information. For example, in Word you could use the following sequence of property calls:

Selection.WholeStory
Selection.Font.Size = 12
Selection.Font.Name = "Georgia"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文