MailMessage mail = new MailMessage(); mail.From = new MailAddress("Admin@tim.com.tw"); mail.Subject = "新書上架通知"; mail.IsBodyHtml = true; // 將圖片放在附件中 mail.Attachments.Add(new Attachment(Server.MapPath("~/Content/images/book.jpg"))); // 附件的唯一值 mail.Attachments[0].ContentId = System.Guid.NewGuid().ToString(); mail.Attachments[0].ContentDisposition.Inline = true; // Img 的圖片路徑寫法 => cid:附件唯一值 mail.Body = string.Format(@" <table border='0' cellpadding='0' cellspacing='0' style='width:100%'> <tr> <td>新書上架</td> <td> <img width=80 height=120 src='cid:{0}' /> </td> </tr> </table>" , mail.Attachments[0].ContentId);
參考來源:KingKong Bruce記事
沒有留言:
張貼留言