MailMessage – 错误打开Excel附件

public void SendMail(string smtpAddress, string subject, string body, bool isBodyHtml, string from, string to, string cc, string bcc,DataTable dt) { SmtpClient smtpClient = null; try { smtpClient = new SmtpClient(); smtpClient.Host = smtpAddress; MailMessage mailMessage = new MailMessage(from, to, subject, body); mailMessage.BodyEncoding = Encoding.UTF8; mailMessage.IsBodyHtml = true; using (MemoryStream memoryStream = new MemoryStream()) { Byte[] contentAsBytes = SerializeData(dt); memoryStream.Write(contentAsBytes, 0, contentAsBytes.Length); memoryStream.Position = 0; Attachment attachment = new Attachment(memoryStream, "test.xls", "application/vnd.ms-excel"); mailMessage.Attachments.Add(attachment); smtpClient.Send(mailMessage); memoryStream.Close(); } } catch (Exception) { } } 

MailMessage生成但附加excel错误提示您正在尝试打开的文件是由不同的扩展名指定的格式。 在打开文件之前validation该文件是否已损坏,并且是否受信任来源的信任。 在打开xsl时,它会生成xsd格式。
请帮忙