【问题标题】:C# Outlook 2007 - How do I access attachment contents directly from my addin?C# Outlook 2007 - 如何直接从我的插件访问附件内容?
【发布时间】:2009-05-05 22:09:09
【问题描述】:

我正在尝试解析基于文本的文件附件(txt、doc 等...)。但是,我似乎无法获取二进制信息本身。我可以得到文件名,我可以将文件保存到某个临时文件夹并从那里打开它,但这看起来很乱。

有没有什么方法可以在不保存、阅读、删除附件的情况下访问附件的内容,或者我只是在追我的尾巴?

【问题讨论】:

    标签: c# outlook outlook-2007


    【解决方案1】:

    Redemption 将在此处为您提供帮助,SafeMailItem.Attachments 集合具有 Attachment 对象,该对象具有属性“AsText” 看看

    http://www.dimastr.com/redemption/

    76梅尔

    【讨论】:

    • 除了看起来不错的 199 美元许可费。我得看看能不能省下钱。
    • 赎回是唯一不错的方法,因为它是扩展 MAPI 的包装并消除了复杂性。
    【解决方案2】:

    您可以使用 Microsoft 架构获取附件的内容 -

       private void GetAttachmentContent(Attachments attachments)
        {
            foreach (Attachment attachment in attachments)
            {
                //microsoft schema to get the attachment content
                string AttachSchema = "http://schemas.microsoft.com/mapi/proptag/0x37010102";
                byte[] filebyte = (byte[])attachment.PropertyAccessor.GetProperty(AttachSchema);
            }
        }
    

    您需要在代码文件中引用:Microsoft.CSharp.dll

    【讨论】:

    • PropertyAccessor.GetProperty 对于大型二进制(例如 PR_ATTACH_DATA_BIN)属性将失败。在 MAPI 级别(C++ 或 Delphi)PR_ATTACH_DATA_BIN 必须使用 ISAttach::OpenProperty 作为 IStream 打开。 PropertyAccessor 不这样做。
    • 你能指定大二进制表示它不能处理的大小吗?
    • 取决于商店提供者。对于在线 Exchange 商店,它可以低至 32kB。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-27
    • 1970-01-01
    • 2011-06-06
    • 2010-10-27
    • 2015-12-15
    • 1970-01-01
    相关资源
    最近更新 更多