From 3b5ae513cb3f18fd01eedc936c7b1bd2137720e5 Mon Sep 17 00:00:00 2001 From: DeProgrammer Date: Thu, 1 Aug 2019 09:56:29 -0500 Subject: [PATCH] Note about Dispose affecting Attachments https://referencesource.microsoft.com/#system/net/System/Net/mail/MailMessage.cs,a22b7e48cd4bc831 Disposing of Attachments also closes the Streams they're using. The problem I had that caused me to dig into the code wasn't relevant to this change, but I saw it as a potential occasional issue. A MailMessage intuitively shouldn't take this kind of ownership of an Attachment that was given to it by an external source since the documentation suggests that Attachments can be reused. In my mind, "not intuitive" means "needs to be clearly documented." --- xml/System.Net.Mail/MailMessage.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xml/System.Net.Mail/MailMessage.xml b/xml/System.Net.Mail/MailMessage.xml index d884e44955b..a4531aa6495 100644 --- a/xml/System.Net.Mail/MailMessage.xml +++ b/xml/System.Net.Mail/MailMessage.xml @@ -93,7 +93,7 @@ Use the property to specify copies of an email message in different formats. For example, if you send a message in HTML, you might also want to provide a plain text version in case some of the recipients use email readers that cannot display HTML content. For an example that demonstrates creating a message with alternate views, see . - Use the property to add attachments to an email message. For an example that demonstrates creating a message with an attachment, see . + Use the property to add attachments to an email message. For an example that demonstrates creating a message with an attachment, see . Calling Dispose on the MailMessage also calls Dispose on each referenced Attachment. After assembling your email message, you can send it by using the or methods. @@ -1408,4 +1408,4 @@ - \ No newline at end of file +