The scenario is that I have a script that does the following in sequence:
- Script that generates a base64 qr code
- Script that sends an email to the user with the base64 qr code
Problem here is that while I tried to embed the email (using MIME) with the <img src={data:image/png:base64, ...} />
, I can view it in my Outlook however unable to view it in my Gmail.
Another alternative that I can think of is attach the base64 as an attachment of the email and thereafter potentially displaying it in the email body. However, for some reason the attachment in the email seems to be corrupted as I can unable to open it.
I have been following closely to the following links to construct my MIME https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html https://github.com/andrewpuch/aws-ses-node-js-examples/blob/master/app.js upload .jpg image attachment in mail using AWS SES from node.js
If you have a better approach to my scenario, do let me know.
The qrCode below refers to the base64 image of a QR Code image such as data:image/png:base64, ...
MIME of the email body
let ses_mail = "From: COMPANY A <" + sender_email + ">\n";
ses_mail = ses_mail + "To: " + receiver_email + "\n";
ses_mail = ses_mail + "Subject: " + subjectTitle + "\n";
ses_mail = ses_mail + "MIME-Version: 1.0\n";
ses_mail = ses_mail + "Content-Type: multipart/mixed; boundary=\"NextPart\"\n\n";
ses_mail = ses_mail + "--NextPart\n";
ses_mail = ses_mail + "Content-Type: text/html; charset=iso-8859-1\n\n";
ses_mail = ses_mail + "<html>\n";
ses_mail = ses_mail + "<body>\n";
ses_mail = ses_mail + "<h2>Registration Successful</h2>\n";
ses_mail = ses_mail + "<p>You can retrieve information through the QR Code provided.</p>\n";
ses_mail = ses_mail + "<img src=\"" + qrCode + "\" alt='image'/>\n";
ses_mail = ses_mail + "</body>\n";
ses_mail = ses_mail + "</html>\n\n";
ses_mail = ses_mail + "--NextPart\n";
ses_mail = ses_mail + "Content-Type: image/png; name=qrCode.png\n\n";
ses_mail = ses_mail + "Content-ID: <idname>\n\n";
ses_mail = ses_mail + "Content-Disposition: attachment; filename=qrCode.png\n";
ses_mail = ses_mail + "Content-Transfer-Encoding: base64\n\n";
ses_mail = ses_mail + qrCode.slice(21) + "\n\n";
ses_mail = ses_mail + "--NextPart--\n\n";