MailMessage.Load(stream) closes the stream

0 votes
asked Mar 10, 2016 by zerajima (210 points)

Is there any way to avoid this, other can copying entire stream to buffer, before passing it to MailMessage.Load?

Applies to: Rebex Secure Mail

1 Answer

+1 vote
answered Mar 10, 2016 by Lukas Pokorny (121,790 points)
selected Mar 11, 2016 by zerajima
Best answer

You can disable closing the input stream by enabling the DoNotCloseStreamAfterLoad option:

var mail = new MailMessage();
mail.Options |= MimeOptions.DoNotCloseStreamAfterLoad;