C# Outlook 2007 - How do I access attachment contents directly from my addin?

瘦欲@ 提交于 2019-12-10 20:13:33

问题


I'm trying to parse text-based file attachments (txt, doc, etc...). However, I can't seem to get to the binary information itself. I can get the filename and I can save the file out to some temporary folder and open it from there, but that seems messy.

Is there any way to access the content of an attachment without saving it, reading it, then deleting it or am I just chasing my tail?


回答1:


Redemption will help you here, SafeMailItem.Attachments collection has Attachment object that has a property "AsText" check out

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

76mel




回答2:


You can get content of an attachment using Microsoft schema -

   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);
        }
    }

You need to ref : Microsoft.CSharp.dll in code file



来源:https://stackoverflow.com/questions/827131/c-sharp-outlook-2007-how-do-i-access-attachment-contents-directly-from-my-addi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!