埋め込み画像として html と添付ファイルを含むメールを送信する質問があります。画像フォルダーの画像を div の背景として使用する方法がわかりません。
ここに私のコード:
SmtpMail oMail = new SmtpMail("TryIt");
SmtpClient oSmtp = new SmtpClient();
oMail.From = "test@emailarchitect.net";
oMail.To = "<my email>";
oMail.Subject = "test";
SmtpServer oServer = new SmtpServer("<smtp server>");
try
{
// Attachment header = oMail.AddAttachment("d:\\mail_header.jpg");
Attachment header = oMail.AddAttachment("images/mail_header.jpg"); // this don't work
Attachment oAttachment = oMail.AddAttachment("d:\\bg_content.jpg");
Attachment Footer = oMail.AddAttachment("d:\\mail_footer.jpg");
string contentID_header = "header";
header.ContentID = contentID_header;
string contentID = "test001@host";
oAttachment.ContentID = contentID;
string contentID_footer = "footer";
Footer.ContentID = contentID_footer;
//how I can use a pic as background
oMail.HtmlBody = "<html><body>"+
"<div style='background-image:url(" + contentID_header + ");width: 800px;height: 50px'></div>" +
"<div><img src=\"cid:" + contentID + "\"></div>" +
"<div><img src=\"cid:" + contentID_footer + "\"></div>" +
"</body></html>";
oSmtp.SendMail(oServer, oMail);
}
catch (Exception ep)
{
txtSimulate.Text = ep.Message;
}