本文介绍了使用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.

我知道

我尝试使用名称空间,而不是名称空间,.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级别存在问题,兑换"将报告该问题,而不是给出模糊的错误消息.

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:\temp\test.msg", olMsg

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

07-23 19:23