使用 EntryID 引用时的 MailItem.SaveAs [英] MailItem.SaveAs when referencing with EntryID

查看:25
本文介绍了使用 EntryID 引用时的 MailItem.SaveAs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发将 Outlook 中的 MailItem(我知道它是 MailItem 而不是任何其他类型)拖放到 Access 备忘录字段中.尝试对 MailItem 对象调用 SaveAs.

I'm developing a drag and drop of a MailItem from Outlook (I know it's a MailItem and not any other type) into an Access memo field. Trying to call SaveAs on a MailItem object.

我明白

错误 287 - 应用程序定义或对象定义的错误.

Error 287 - Application-defined or object-defined error.

我尝试过使用命名空间,而不是使用命名空间,使用 .Item 等.

I've tried using the namespace, not using the namespace, using .Item, etc.

这是我当前的代码:

Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")

Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")

Dim olMail As Outlook.MailItem
Set olMail = olNs.GetItemFromID(olNs.Application.ActiveExplorer.Selection(1).EntryID)

olMail.SaveAs strPathAndFile, Outlook.OlSaveAsType.olMSG

Access 2010、Outlook 2010 均为 32 位.Win 7 机器是 64 位的.

Access 2010, Outlook 2010 both 32 bit. Win 7 machine is 64 bit.

在全 32 位机器上试过,同样的错误.

Tried it on an all 32-bit machine, same error.

在下面尝试了 Dmitry 的代码,同样的错误.

Tried Dmitry's code below, same error.

推荐答案

真的没必要重新打开留言:

There is really no need to reopen the message:

Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.ActiveExplorer.Selection(1)
olMail.SaveAs strPathAndFile, Outlook.OlSaveAsType.olMSG

其次,strPathAndFile 变量的值是多少?

Secondly, what is the value of the strPathAndFile variable?

作为测试,您可以安装 Redemption 并尝试以下脚本(您可以从OutlookSpy - 单击脚本,按钮,粘贴脚本,单击运行).如果 MAPI 级别出现问题,Redemption 将报告它而不是给出模糊的错误消息.

As a test, can you install Redemption and try the following script (you can run it from OutlookSpy - click Script, button, paste the script, click Run). If there is a problem on the MAPI level, Redemption will report it instead of giving an obscure error message.

  set Session = CreateObject("Redemption.RDOSession")
  Session.MAPIOBJECT = Application.Session.MAPIOBJECT
  set Msg = Session.GetMessageFromID(Application.ActiveExplorer.Selection(1).EntryID)
  Msg.SaveAs "c:	emp	est.msg", olMsg

这篇关于使用 EntryID 引用时的 MailItem.SaveAs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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