MailItem.GetInspector.WordEditor 不返回任何内容 [英] MailItem.GetInspector.WordEditor returns Nothing

查看:93
本文介绍了MailItem.GetInspector.WordEditor 不返回任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用在 Outlook 2013 中打开的 VB.Net 撰写电子邮件.我需要以用户设置的默认字体显示内容.

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.

现在我需要获取默认字体并设置为电子邮件.当我尝试时,它在一个地方返回 null.

Now i need to get the default font and set to the email. When i tried it returns null at one place.

//代码:

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?

来源

推荐答案

WordEditor 属性在显示消息之前可能不可用.

WordEditor property might not be available until the message is shown.

尝试简单地设置 MailItem.HTMLBody 属性.

Try to simply set the MailItem.HTMLBody property.

这篇关于MailItem.GetInspector.WordEditor 不返回任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆