PropertyAccessor.GetProperty( PR_ATTACH_DATA_BIN) Outlook 附件失败 [英] PropertyAccessor.GetProperty( PR_ATTACH_DATA_BIN) fails for outlook attachment

查看:77
本文介绍了PropertyAccessor.GetProperty( PR_ATTACH_DATA_BIN) Outlook 附件失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个 OutLook 插件来捕获带有大附件的电子邮件,并将附件替换为可用于下载附件的 URL.

I need to create an OutLook add-in that catches emails with large attachments and replaces the attachment with a URL that can be used to download the attachment.

我发现 this 显示了如何修改附件在发送它之前看起来是一个很好的起点,但问题是调用:

I found this which shows how to modify an attachment before sending it that looked like a good starting point but the problem is that the call:

const 字符串 PR_ATTACH_DATA_BIN ="http://schemas.microsoft.com/mapi/proptag/0x37010102";

const string PR_ATTACH_DATA_BIN = "http://schemas.microsoft.com/mapi/proptag/0x37010102";

var 附件数据 =附件.PropertyAccessor.GetProperty(PR_ATTACH_DATA_BIN);

var attachmentData = attachment.PropertyAccessor.GetProperty( PR_ATTACH_DATA_BIN);

失败并显示属性未知或无法找到的错误.

fails with an error saying the property is unknown or cannot be found.

我可以调用attachment.PropertyAccessor.GetProperty() 来获取附件类型1 (ATTACH_BY_VALUE) 所以我应该能够通过attachment.PropertyAccessor.GetProperty(PR_ATTACH_DATA_BIN) 获取数据

I can call attachment.PropertyAccessor.GetProperty() to get the attachment type which is 1 (ATTACH_BY_VALUE) so I should be able to get the data with attachment.PropertyAccessor.GetProperty(PR_ATTACH_DATA_BIN)

我想知道这里是否存在权限问题.我在这里看到:dev.office.com/docs/add-ins/outlook/understanding-outlook-add-in-permissions 有 Outlook 加载项权限,如果我没有 ReadWriteItem 访问权限,那么这可能会失败.我不知道这是如何或在哪里设置的.他们提到在清单中设置了它,但我不知道在哪里可以做到这一点.

I am wondering if there is a privilege problem here. I see here: dev.office.com/docs/add-ins/outlook/understanding-outlook-add-in-permissions that there are Outlook add-in permissions and that if I did not ReadWriteItem access then this could fail. I do not know how or where this is set though. They mention about it being set in the manifest but I do not see where I can do that.

我使用的是 Visual Studio Community 2015.

I am using Visual Studio Community 2015.

推荐答案

Outlook 对象模型无法使用 PropertyAccessor.GetProperty 检索大型二进制或字符串 MAPI 属性.在低级别(仅限扩展 MAPI、C++ 或 Delphi),IMAPIProp::GetProps() 不适用于大型 PT_STING8/PT_UNICODE/PT_BINARY 属性.它们必须作为 IStream (IMAPIProp::OpenProperty(PR_ATTACH_DATA_BIN, IIS_IStream, ...)) 打开.如果使用 Redemption 是一个选项,它的附件对象公开 AsTextAsArrayAsStream 等属性.

Outlook Object Model cannot retrieve large binary or string MAPI properties using PropertyAccessor.GetProperty. On the low level (Extended MAPI, C++ or Delphi only), IMAPIProp::GetProps() does not work for the large PT_STING8 / PT_UNICODE / PT_BINARY properties. They must be opened as IStream (IMAPIProp::OpenProperty(PR_ATTACH_DATA_BIN, IIS_IStream, ...)). If using Redemption is an option, its attachment objects expose AsText, AsArray, AsStream, etc properties.

  set Session = CreateObject("Redemption.RDOSession")
  Session.MAPIOBJECT = Application.Session.MAPIOBJECT
  set item = Session.GetMessageFromID(Application.ActiveExplorer.Selection(1).EntryID)
  for each attach in item.Attachments
    MsgBox attach.AsText
  next

这篇关于PropertyAccessor.GetProperty( PR_ATTACH_DATA_BIN) Outlook 附件失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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