So below is the code i'm using. Basically it just loops through an array, adds the files to the zip, then saves the zip to a memory stream and then emails the attachment.
When I look at the item in debug I can see that the zipfile has about 20 megabytes of data. When i receive the attachment it only has about 230 bits of data and there is no content. Any thoughts?
byteCount = byteCount + docs[holder].FileSize;
if (byteCount > byteLimit)
{
//create a new stream and save the stream to the zip file
System.IO.MemoryStream attachmentstream = new System.IO.MemoryStream();
zip.Save(attachmentstream);
//create the attachment and send that attachment to the mail
Attachment data = new Attachment(attachmentstream, "documentrequest.zip");
theMailMessage.Attachments.Add(data);
//send Mail
SmtpClient theClient = new SmtpClient("mymail");
theClient.UseDefaultCredentials = false;
System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential("bytebte", "2323232");
theClient.Credentials = theCredential;
theClient.Send(theMailMessage);
zip = new ZipFile();
//iterate Document Holder
holder++;
}
else
{
//create the stream and add it to the zip file
//System.IO.MemoryStream stream = new System.IO.MemoryStream(docs[holder].FileData);
zip.AddEntry("DocId_"+docs[holder].DocumentId+"_"+docs[holder].FileName, docs[holder].FileData);
holder++;
}
The issue is here Attachment data = new Attachment(attachmentstream, "documentrequest.zip");
once I look at the attachment it has a size of -1 So whats the proper way to attach this item?