I am using MailMessage and ReportViewer.I am using below code
snippet, my problem is that I get the email and it has attachment Temp.pdf, but
the attachment doesnt open.
=========
byte[] buffer = ReportViewer1.LocalReport.Render("pdf", null,
out mimeType, out encoding, out extension, out streamids, out warnings);
var
f = System.IO.Path.GetTempFileName();
f = System.IO.Path.ChangeExtension(f,
extension);
var fs = new FileStream(f, FileMode.Create);
fs.Write(buffer,
0, buffer.Length);
ContentType ct = new
ContentType(MediaTypeNames.Application.Pdf);
var at = new Attachment(fs,
ct);
at.ContentDisposition.FileName =
"Temp.pdf";
at.ContentDisposition.DispositionType =
DispositionTypeNames.Attachment;
msg.Attachments.Add(at);
smtpClient.Send(msg);
=============================
It says - "dobe reader could not open
'Temp.pdf' because it is either not a supported file type or because the file
has been damaged (for example, it was sent as an email attchment and wasn't
correctly decoded)."
What could be wrong in my code. I get buffer filled up with
11342 bytes
Thanks in advance....