Add an Example for MimeMessage.Attachments Property
nitechservices opened this issue · comments
Meta-Craft commented
Please add an example for MimeMessage.Attachments Property.
TODO (optional): Describe a specific scenario you would like to see addressed.
Help Topic: http://www.mimekit.net/docs/html/P_MimeKit_MimeMessage_Attachments.htm
Jeffrey Stedfast commented
I have examples of this in the README and FAQ, but I should probably also add it to the API docs.
foreach (var attachment in message.Attachments) {
var fileName = attachment.ContentDisposition?.FileName ?? attachment.ContentType.Name;
using (var stream = File.Create (fileName)) {
if (attachment is MessagePart) {
var rfc822 = (MessagePart) attachment;
rfc822.Message.WriteTo (stream);
} else {
var part = (MimePart) attachment;
part.Content.DecodeTo (stream);
}
}
}
Jeffrey Stedfast commented
The property already has/had an example on the API docs website. I'm not sure why you requested an example when one already existed?