简体   繁体   中英

HTML Email Body Base64 Image not showing

I am trying to send an email on my application (asp.net C#)I tried every answer on SO to display base64 image on the email body. but nothing workout so far. if anyone helps me to solve this problem that will be great. This is HTML Code

<tr style="min-height:60px;margin-top:50px;width:100%;padding: 0px;color: black;clear: left;text-align: center;border: 1px solid black;margin-top: 40px;margin-bottom:40px;">
           <td style="margin-top:100px;height:60px; background-position-x: center;background-position-y: center;background-size: cover;background-repeat: no-repeat;">
               <img src="##FooterImage" style="margin-left: 73%;" />
           </td>
       </tr>

    emailBodyLoaded = emailBodyLoaded.Replace("##FooterImage", "'cid:" + iconResource.ContentId + @"'");
    byte[] iconBytes = new BLL.Core.Domain.items(new ageContext()).GetitemsLogo(inspData.Rows[0]["ItemID"].ToString());
    System.IO.MemoryStream iconBitmap = new System.IO.MemoryStream(iconBytes);
    LinkedResource iconResource = new LinkedResource(iconBitmap, MediaTypeNames.Image.Jpeg);
    iconResource.ContentId = "Icon";

first you should check if your base64 string is valid.you can do that using any of the online tools like base64-image .how ever please refer to this EXAMPLE fiddle which displays a base64 image using html img control.

EDIT: please check in your 'IMG' src have data:image/jpeg;base64, before the base64 string.this where it determines the image format.if this doen't work please try replacing 'jpeg' with 'png' eg:- data:image/png;base64,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM