在发送电子邮件Outlook 2016时,内嵌图像将以.bin文件形式出现

时间:2017-08-16 12:11:34

标签: outlook smtp html-email email-attachments inline-images

  

我正在尝试在html中发送内联图片,它将以.bin文件的形式发送

     

我已经阅读了这个Quesstion的答案

Sending an e-mail with an image inline that is attached comes up as ATT00001 on some computers 但仍然无法解决

string DexuslogoImage2 = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images\\DexusTenantNotice.png");
string strBody = strBody.Replace("##DexusNoticeLogo##", "cid:Dexuslogo1");

dynamic htmlView = AlternateView.CreateAlternateViewFromString(_Body.ToString(), null, "text/html");
if (!string.IsNullOrEmpty(_EmailLogo)) {
    LinkedResource logo = new LinkedResource(_EmailLogo);
    logo.ContentId = "Dexuslogo1";
    htmlView.LinkedResources.Add(logo);
}

LinkedResource logo1 = new LinkedResource(_EmailLogo1);
logo1.ContentId = "Dexuslogo2";

htmlView.LinkedResources.Add(logo1);
aMessage.AlternateViews.Add(htmlView);

1 个答案:

答案 0 :(得分:1)

  

我发现当_EmailLogo1_EmailLogo为空时需要回答.bin文件   检查它是否为空!!

dynamic htmlView = AlternateView.CreateAlternateViewFromString(_Body.ToString(), null, "text/html");
if (!string.IsNullOrEmpty(_EmailLogo1)) {
    LinkedResource logo = new LinkedResource(_EmailLogo);
    logo.ContentId = "Dexuslogo2";
    htmlView.LinkedResources.Add(logo);
}
if (!string.IsNullOrEmpty(_EmailLogo))
{
LinkedResource logo1 = new LinkedResource(_EmailLogo1);
logo1.ContentId = "Dexuslogo2";
htmlView.LinkedResources.Add(logo1);
aMessage.AlternateViews.Add(htmlView);
}