Create MapiAttachmentCollection.Add overload that accepts STREAM?

We are processing many messages with attachments and need the ability to efficiently add attachments to messages. Newing up byte[] array’s thousands of times can fragment memory and result in ‘OutOfMemory Exceptions’ due to the in ability to create contiguous memory. Using streams in chunks avoids all of this.

Would it be possible for the Attachments to be added using streams in a way describe here:

Thanks!

Jon

@jgilpin,

Thank you for contacting Aspose support team.

We have logged a ticket under Id:EMAILNET-39010 for detailed analysis later. We will write back here as soon as some feedback is ready to share.

@jgilpin,

Could you please mention the usual size of attachments and usual number of times for which this activity is performed? This information is required for our analysis here.

@jgilpin,

We have implemented this feature and would request you to please try it at your end. Please let us know if it meets your requirements. You can download the version from attachment to this thread.EMAILNET-39010.zip (2.6 MB) 39010.zip (1.4 KB)

Public API Changes for this purpose are:

Methods:

  • MapiAttachmentCollection.Add(string name, DataSegment data) - Adds the new attachment as part of byte array

Classes:

  • DataSegment - Represent a part of array
    ** int Offset - Return the offset of the array part
    • int Length - Return the length of the array part
    • bool IsNotNull - Return true, if the stored value is not null, false otherwise
    • bool IsNull - Return true, if the stored value is null, false otherwise
    • bool IsEmpty - Return true, if the stored value is null or empty, false otherwise
    • bool HasData - Return true, if the stored value is not null and not empty, false otherwise
    • DataSegment Slice(int from, int count) - Return the slice from the position “from” of length “count”
    • DataSegment Slice(int from) - Return the slice from the position “from”
    • byte this[int index] - Return the byte of the serialized value at index
    • void CopyTo(int srcOffset, byte[] dest, int destOffset, int count) - Copies a specified number of bytes from a source array starting at a particular offset to a destination array starting at a particular offset.