我的解决方案中有一些存储在Resources.resx文件中的图像.我想在我的电子邮件中使用这些图片.我已将图像加载到变量中:
Bitmap myImage = new Bitmap(Resources.Image);
Run Code Online (Sandbox Code Playgroud)
现在我想把它放在我用来创建HTML电子邮件的AlternateView字符串中的HTML中.只是需要一些帮助.
这是HTML字符串(部分):
body += "</HEAD><BODY><DIV style='height:100%; width:700px;'><div style='height:70px; width:700px; background-color:red;'><img src='" + myImage + "' width='104' height='27' alt='img' style='margin: 20px 0px 0px 20px;'/></div>
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激谢谢!
编辑:这是整个代码块.我认为我接近它,只是缺乏经验阻碍这里:)我尝试将其转换为像我所说的那个让我更远的字节.仍然没有渲染图像.这里有些东西我做得不对.非常感谢大家帮助大家!这是代码(图像所需的HTML在字符串体的3行=代码中):
if (emailTo != null)
{
Bitmap myImage = new Bitmap(Resources.comcastHeader);
ImageConverter ic = new ImageConverter();
Byte[] ba = (Byte[])ic.ConvertTo(myImage, typeof(Byte[]));
MemoryStream image1 = new MemoryStream(ba);
LinkedResource headerImage = new LinkedResource(image1, "image/jpeg");
headerImage.ContentId = "companyLogo";
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("" + emailTo + "");
message.Subject = "" + customer …Run Code Online (Sandbox Code Playgroud)