How can I get inline attachments from Outlookmailitem? & # 8594; Get attachments from * .msg files

I am currently viewing Outlook-addin (Outlook 2007) in C #, and I need to save the embedded attachments (usually images in BMP format).

I meen attachments nested by insert ([CRTL] + [V])

When I try to save all attachments:

foreach (Outlook.Attachment a in mail.Attachments) { a.SaveAsFile(path); } 

I have a ComException (if the attachment is embedded in another, it will save it correctly)

Can someone help me - please; -D


EDIT At the moment, I'm thinking of a workaround. I tried to export the "OLE" object (I think it is ole), but it was not successful.

Now I am testing the export of * .msg. If you open the * .msg file with 7zip fileexplorer, you will get several files and folders. Inside the “attachments” folder, you can find the “CONTENT” file, which is an embedded BMP file. But I can not access * .msg using GZip (in.net). I also tried the 7zip SDK sample , but I have an error - "System error: invalid function".

If I try Gzip on .net - I will get a bad magic number exception or something else - so the problem is in the file.

Can someone explain to me how I can extract files?

+4
source share

Source: https://habr.com/ru/post/1436546/


All Articles