【问题标题】:Outlook OLE Automation: BodyFormat not supported?Outlook OLE 自动化:不支持 BodyFormat?
【发布时间】:2018-08-23 00:40:39
【问题描述】:

我正在尝试使用 OLE 自动化在 Outlook 中发送电子邮件。目前,我正在使用 VBS 进行测试。当它工作时,我会切换到另一种支持 OLE/COM 的语言。

我的代码的问题是,我收到错误 800a0005 "Invalid procedure call" with argument 'BodyFormat'。

根据documentation of MicrosoftBodyFormat 自 Outlook 2003 以来就存在。我正在使用 Outlook 2010 进行测试。

我的代码:

Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")

Set newMail = ol.CreateItem(olMailItem)

With newMail
       .BodyFormat = olFormatHTML
       .HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
       .Display
End With

背景:目前部分客户收到TNEF格式的邮件,无法打开邮件附件winmail.dat。所以我试图强制 Outlook 使用 HTML 而不是 RichText。

我能做什么?

【问题讨论】:

    标签: vbscript outlook


    【解决方案1】:

    默认不定义常量olFormatHTML

    VBS 代码的开头添加以下行:

    Const olFormatHTML = 2
    

    【讨论】:

      猜你喜欢
      • 2011-03-18
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-28
      • 2011-01-31
      • 1970-01-01
      相关资源
      最近更新 更多