Outlook确定用户默认邮件字体样式和大小

时间:2017-08-16 12:43:46

标签: html vba outlook outlook-vba

早上好 - 我正在尝试以编程方式从Access到Outlook草拟电子邮件。

我相信我已经正确地想出了如何创建电子邮件,但无法理解如何使用用户默认邮件消息字体作为字体类型。所有消息都出现在Times New Roman,第12页。

我发现很多关于如何将字体设置为某种样式的文章,但我想使用用户的默认Outlook字体设置。

Sub testHTML()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

          ' Create the Outlook session.
          Set objOutlook = CreateObject("Outlook.Application")

          ' Create the message.
          Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

          With objOutlookMsg
              ' Add the To recipient(s) to the message.
'              Set objOutlookRecip = .Recipients.Add("Whatever Email")
'              objOutlookRecip.Type = olTo

             .Subject = "Testing"
             .Display

             'Create HTML body, which will contain a hyperlink
                objOutlookMsg.HTMLBody = "This is the body of the email, which contains a link to Google.  " & _
                                        "<a href='http://www.google.com'>www.google.com<a/>. " & _
                                        "Can you please help me figure out the font for the whole message?  " & _
                                        "Why does it default to Times New Roman point 12 instead of the users' default mail font?"
        End With
End Sub

3 个答案:

答案 0 :(得分:0)

您可以使用以下内容:

objOutlookMsg= "<BODY style=font-size:11pt;font-family:Calibri>This is the body of the email, which contains a link to Google.  " & _
                                    "<a href='http://www.google.com'>www.google.com<a/>. " & _
                                    "Can you please help me figure out the font for the whole message?  " & _
                                    "Why does it default to Times New Roman point 12 instead of the users' default mail font?"</BODY>"

答案 1 :(得分:0)

您好我检查您的问题。 Outlook不支持外部字体。所以Times New Roman是outlook的默认字体。您可以使用系统默认字体。 Arial字体。另外,您应该定义内联字体。这是处理它的最佳方式。

答案 2 :(得分:0)

设置存储在 HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\MailSettings(其中“16.0”是Outlook版本)。嵌入字体的名称是ComposeFontSimple二进制值; ComposeFontComplex似乎包含用于新邮件的HTML模板。