Base64 image shows in outlook email body but in Gmail it does not show the image, Gmail is not recognising the base64 string

78 Views Asked by At

I have an email template which is in Azure, in asp.net core api iam generating QR in base64 string and i use that as that as img src (like this : <img src="{{QRstring}}") the value of {{QRstring}} is like "data:image/png;base64,iVBOR........................................VORK5CYII="
now this works perfectly for Outlook but in Gmail it does not display

what approach i can use where i can show QR to all Email clients without any issues?

this is how iam generating QR:

public async Task<string> QRGenerate(Model model)
        {
            QRCodeData qrCodeData;
            string qrData = $"abcd";

            using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
            {
                qrCodeData = qrGenerator.CreateQrCode(qrData, QRCodeGenerator.ECCLevel.Q);
            }

            var imgType = Base64QRCode.ImageType.Png;
            var qrCode = new Base64QRCode(qrCodeData);
            string qrCodeImageAsBase64 = "data:image/png;base64," + qrCode.GetGraphic(20, SixLabors.ImageSharp.Color.Black, SixLabors.ImageSharp.Color.White, true, imgType);

            return qrCodeImageAsBase64;
        }

whatever string value i get from qrCodeImageAsBase64 iam using it in that {{QRstring}}, again this works for Outlook but not Gmail

0

There are 0 best solutions below