Apr 20, 2007

Convert string to Stream

   private void AddAttachmentFromStream(MailMessage message, String data, String attachmentName)
{
MemoryStream stream = new MemoryStream(UTF32Encoding.Default.GetBytes(data));
stream.Position = 0;
// Create a new attachment, add the attachment to the supplied message.
Attachment att = new Attachment(stream, attachmentName);
message.Attachments.Add(att);
}

kick it on DotNetKicks.com

No comments: