2017-08-16 64 views
1

早上好 - 我想從訪問Outlook程序是撰寫電子郵件。展望確定用戶的默認郵件字體樣式和大小

我相信我已經想通妥善如何創建電子郵件,但無法理解如何使用用戶的默認郵件字體的字體類型。所有消息都上來了宋體,PT 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 

回答

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>" 
+0

謝謝你的建議 - 我可以用你的建議,如果我想將它設置爲宋體大小11。但是,我不想硬編碼的字體 - 我喜歡簡單地讓它默認爲用戶設置自己的展望消息。你有其他建議嗎? – blimbert

+0

您可以使用您想要的默認字體,因爲HTML只有3字體和將選擇哪個是存在的。 –

0

您好我檢查你的問題。 Outlook不支持外部字體。所以Times New Roman是Outlook的默認字體。您可以使用系統默認字體。 Arial字體。另外,你應該定義你的字體內聯。這是處理它的最好方法。

0

設置存儲在 HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\MailSettings(其中「16.0」是Outlook版本)。嵌入字體的名稱是ComposeFontSimple二進制值; ComposeFontComplex似乎包含用於新消息的HTML模板。