Sorry if this is the wrong forum, couldn't find a mail or IO forum. I'm trying to attach a memorystream as an attachment to an email, however the file is always empty. I'm using a streamwriter to write the text in to the memorystream, I then flush the streamwriter and I can see the memorystream has data. However when I attach the memorystream to the email the file is always empty. I can't see what I'm doing wrong. Any help would be great. The code is:
System.IO.MemoryStream memorystream = new System.IO.MemoryStream();
System.IO.StreamWriter streamwriter = new System.IO.StreamWriter(memorystream);
Attachment data = new Attachment(memorystream, fName, MediaTypeNames.Application.Octet);
SmtpClient smtp = new SmtpClient();
var4 is a string of XML data.
View Complete Post