hMailServer.Tests.Common.StringExtensions.ToAttachment C# (CSharp) Méthode

ToAttachment() public static méthode

public static ToAttachment ( this data, string name = "attachment.txt" ) : System.Net.Mail.Attachment
data this
name string
Résultat 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);

        }
    }
StringExtensions