public static ToAttachment ( this data, string name = "attachment.txt" ) : System.Net.Mail.Attachment | ||
data | this | |
name | string | |
Результат | System.Net.Mail.Attachment |
public static Attachment ToAttachment(this string data, string name = "attachment.txt")
{
var memoryStream = new MemoryStream();
var streamWriter = new StreamWriter(memoryStream);
streamWriter.Write(data);
streamWriter.Flush();
memoryStream.Position = 0;
return new Attachment(memoryStream, name);
}
}