网页转PDF作为邮件附件
Nuget 引入 OpenHtmlToPdf
1 using (WebClient wc = new WebClient()) 2 { 3 wc.Encoding = Encoding.UTF8; 4 wc.UseDefaultCredentials = true; 5 string html = wc.DownloadString(URL); 6 7 var document = Pdf.From(html); 8 9 var result = document.Content(); 10 11 var ms = new System.IO.MemoryStream(result); 12 var fn = string.Format("quotation_{0}", filenme); 13 14 return new Attachment(ms, fn, "application/pdf"); 15 }