MailMessage Mailmsg = new MailMessage();
Mailmsg.From = new MailAddress(fromAddress, fromname);
Mailmsg.To.Add(new MailAddress(toAddress, toname));
Mailmsg.Subject = subject;
Mailmsg.Body = body;
Mailmsg.IsBodyHtml = true;
if (filename.Trim() != "")
Mailmsg.Attachments.Add(new Attachment(filename));
Mailmsg.BodyEncoding = System.Text.Encoding.UTF8;
Mailmsg.Priority = MailPriority.High;
SmtpClient smtp = new SmtpClient(smtpserver, port);
smtp.Credentials = new System.Net.NetworkCredential(fromAddress, emailpwd);
smtp.EnableSsl = false;//gmail需要设置为 true;
if (fromAddress.ToLower().IndexOf("@gmail.com") > 0)
smtp.EnableSsl = true;
smtp.Send(Mailmsg);
邮件发送后 附件不能预览。。
开始使用NPOI 1.2.5生成的excel可以预览
后来使用2.0生成的不能预览了
请问是怎么个回事。。
是npoi的原因还是MailMessage的原因
------解决思路----------------------
Attachment第二个参数用application/vnd.ms-excel试试
------解决思路----------------------
不能御览,就换一个算了。