MemoryStream ms = new MemoryStream();
PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
pcl.Component = ASPxGridViewExporter1;
pcl.Margins.Left = pcl.Margins.Right = 50;
pcl.Landscape = true;
pcl.CreateDocument(false);
pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1;
pcl.ExportToPdf(ms);
MailMessage mailMsg = new MailMessage();
mailMsg.To.Add("n@x.net");
MailAddress mailAddress = new MailAddress("info@x.net");
mailMsg.From = mailAddress;
mailMsg.Subject = "";
mailMsg.Body = "";
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Application.Pdf);
System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(ms, "x.pdf");
mailMsg.Attachments.Add(attach);
SmtpClient smtpClient = new SmtpClient("192.168.1.200", 25);
smtpClient.UseDefaultCredentials = false;
smtpClient.Send(mailMsg);
ms.Close();
そして、添付ファイルに 153B のファイルを取得しています。
どこが間違っていますか?