Hi,
I am trying to use Microsoft.Exchange.Data.Mime.MimeWriter (and MimeReader )
to convert a email object (originally in TNEF binary encoding ) to TNEF base64 encoding and save
it to an eml file.
When writing the part context, the eml always append additional data after the base64 attachment.
This is my program flow:
MimeWriter wrter = new MimeWriter();
MimeReader reader = MimeReader(email.GetMimeReadStream());
// copy header part skipped
// convert body part
// add 2 more headers
writer.WriteHeader("Content-Transfer-Encoding", "base64");
writer.WriteHeader("Content-Disposition", "attachment;filename=\"winmail.dat\"");
Steam rawInput = email.TnefPart.GetRawContentReadStream();
byte[] buf = new byte[1024*16];
int readb = 0;
EncoderStream sx = new EncoderStream(rawInput, new Base64Encoder(), EncoderStreamAccess.Read);
while ((readb = sx.Read(buf, 0, buf.Length)) > 0)
{
writer.WriteRawContent(buf, 0, readb);
}
writer.EndPart();
I also writer the output from the EncoderStream to another file (not shown in above)
and compare the result with the above eml and found that additional data is appended
at the end.
This make the base64 decode failed when processing the eml by another system.
Can anybody help ?
Thanks!