How to access Outlook email application in C # without saving it in a new place?

I am using Microsoft.Office.Interop.Outlook in C # to access my mailbox and search for messages with specific file attachments. I need to interact with attachments.

Currently, I save the file in a new location and get it from there. This copying process slows me down. Ideally, I would like to access the file from the place where it is stored in memory, but null is returned in the Outlook.Attachment.PathName field.

Messages are stored on the Exchange server.

Can I access them directly or do I need to continue saving files?

+7
c # attachment outlook outlook-addin
source share
2 answers

Outlook.Attachment.PathName implies a disk location. Attachment - file; if you want to interact with it, you should consider it as a file, which means that it saves it on a local drive.

The Outlook.Attachment object does not actually contain an attached file; it contains a link to the attached file with some associated metadata.

+3
source share

I don't know if this is possible in any way using the Outlook object model, but the MAPI certainly allows you to.

You need to open the message MAPIObject , IMessage . From there, use IMessage::OpenAttach() , which returns IAttach .
The investment size is stored in PR_ATTACH_SIZE , the actual data in PR_ATTACH_DATA_BIN .

As always, Redemption probably has an easier way to do this.

change
Access through MAPI - this is what Outlook does anyway - should be fast enough, at least when using the Exchange caching mode.

+3
source share

All Articles