C# Outlook 2007 - How do I access attachment conte

2019-07-06 01:44发布

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?

2条回答
地球回转人心会变
2楼-- · 2019-07-06 02:23

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

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

76mel

查看更多
Evening l夕情丶
3楼-- · 2019-07-06 02:36

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

查看更多
登录 后发表回答