问题
I'm composing an email using VB.Net which is opened in Outlook 2013
. I need to the contents to be displayed in its default font which is set by the user.
Now i need to get the default font and set to the email. When i tried it returns null
at one place.
//Code:
Private m_valDefaultFontSpec As DefaultFont
Sub GetDefaultFontSpec(Optional blnGetReplyFont As Boolean = False)
Dim objDoc As Document
Dim rng As Range
Dim objDummy As MailItem
On Error Resume Next
' Create a "dummy" mail object,
Set objDummy = Application.CreateItem(olMailItem)
' Get the document object from the current "dummy mail" object.
Set objDoc = objDummy.GetInspector.WordEditor //returns nothing here
' Get the range of the word document object.
Set rng = objDoc.Range
' Get some font properties from the given range.
With rng
m_valDefaultFontSpec.Name = .Font.Name
m_valDefaultFontSpec.Size = .Font.Size
m_valDefaultFontSpec.Bold = .Font.Bold
m_valDefaultFontSpec.Color = .Font.Color
m_valDefaultFontSpec.Italic = .Font.Italic
End With
' Finished with the "dummy" mail, close it.
objDummy.Close olDiscard
On Error GoTo 0
End Sub
Where am i wrong? Any help?
Source
回答1:
WordEditor
property might not be available until the message is shown.
Try to simply set the MailItem.HTMLBody
property.
来源:https://stackoverflow.com/questions/38119333/mailitem-getinspector-wordeditor-returns-nothing