foreach (var attachment in message.Attachments) {
using (var stream = File.Create ("fileName")) {
if (attachment is MessagePart) {
var part = (MessagePart) attachment;
part.Message.WriteTo (stream);
} else {
var part = (MimePart) attachment;
part.Content.DecodeTo (stream);
}
}
}
1条答案
按热度按时间n1bvdmb61#
您正在保存整个MIME对象(包括标头)。您需要做的是保存内容。