I have a MapiAttachment
object for which I’d like to set the body of the attachment, which I have coming from a network stream in blocks. I appreciate I can accumulate all the blocksof data into a byte[]
then assign it using MapiAttachment.BinaryData = mybytes
but is there any way I can make use of the fact that the data is coming in chunks in order to avoid having that data all in memory at once?
For instance, I would like to give the stream to the MapiAttachment
and let it read the data, such as MapiAttachment.BinaryDataFromStream(mystream)
, or perhaps append the blocks to the existing BinaryData
(but I suspect that would cause more memory allocation).
I appreciate eventually all the attachment data is going to be in memory in the MapiAttachment
instance, I’m just trying to reduce the number of duplicates to be memory efficient.
The same question applies to the body of an email and MapiMessage.Body
.