Niklas Kjellander wrote:
The scenario is quite simple. I want to add a file as an attachment to a mail message and serialize the message to disk. Maybe this was not really what you wanted me to describe (I'm not sure what you mean by "in regards to MIME")?

Thank you, that's it. Though I don't exactly understand what you plan to do with the message later (cause as said such message can hardly be sent anywhere).

Quote

Niklas Kjellander wrote:
By the way, are you going to clone the DataStream property or not when cloning a message part? I feel that this thread kind of lost it focus on the initial topic.

Definitely not. Cloning a DataStream causes unwanted consumption of resources, and copying the reference to original causes troubles later. So it's up to you how to deal with this.

We have customers that send mails with large attachments. In our product the user composes messages in a "scripting environment" and therefore I cannot give you a strait answer what is to be done with the message later on, it's all up to the user of our product.

Also, I've noticed that AssembleMessage seems to make the process allocate a lot of memory. For example if the message contains an attachment where the DataStream property of the attachment part is a FileStream, the call to AssembleMessage makes the process allocate additional memory that equals to three times the size of the attachment.

Yes, it does, and this is where your code crashes (due to out of memory error) when you attach 170 Mb large file. We will optimize this part, though it's not that simple -- when you attach the file, MIME assembler must encode it to base64 and convert to destination charset. So temporary streams must be allocated one way or another. We will probably need to extend the assembler with OnTemporaryStreamNeeded event so that you could allocate a stream on the disk.

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.