0

i am trying to send Inline image in html and it is coming as .bin file

i have already read the answer of this Quesstion

Sending an e-mail with an image inline that is attached comes up as ATT00001 on some computers but still not able to solve it

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);
Community
  • 1
  • 1
  • you should have commented on the earlier question to see if the OP had found an answer. – Syfer Aug 16 '17 at 12:48

1 Answers1

1

i have found answer .bin file comes when _EmailLogo1 and _EmailLogo are empty so need to check if it's empty or not !!

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);
}