Send QR code via email

Hi,
I want to send QR via email to user. However, I am stuck with coverting output of QR Code module to Buffer or Base64, which can be used to send to user via email.
I am using now this QRCode module:
QRCode module

Any help will be really appreciated.
Thanks

attach a debug node to the output & show us what the qrcode node sends.

I suspect it is already a base64 string (maybe a data uri that can be trimmed and converted to a buffer)

This is the output of QRCode module.


Actually, I want to convert JWT to QR Code then send it to user but for this moment, I just want to test sending QR Code with a random string.

As I suspected, it is a data URI.

So you have 2 options...

  1. use a function and remove the part up to iVB then send it through a base64 node to convert to a binary buffer & add it to the email.
  2. Build a html email with an img with the src set to that data URI
1 Like

For the test, I used your flow with input string is this part

iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAYAAABUmhYnAAAAAklEQVR4AewaftIAAAKkSURBVO3BQW7sWAwEwSxC979yjpdcPUCQusfmZ0T8wRqjWKMUa5RijVKsUYo1SrFGKdYoxRqlWKMUa5RijVKsUYo1SrFGKdYoFw8l4ZtUvikJ36TyRLFGKdYoxRrl4mUqb0rCHUk4UXlC5U1JeFOxRinWKMUa5eLDknCHyh1J+D8l4Q6VTyrWKMUapVijXAyj0iXhJAmdyl9WrFGKNUqxRrkYJgmdSpeEyYo1SrFGKdYoFx+m8k0qXRI6lS4JT6j8JsUapVijFGuUi5clYbIk/GbFGqVYoxRrlIuHVH4zlS4Jd6j8JcUapVijFGuUi4eS0Kl0SXiTSqdykoROpUvCSRLepPJJxRqlWKMUa5SLh1ROVN6UhG9S6ZLQqXRJOEnCicoTxRqlWKMUa5SLh5LQqXRJ+CSVLgmdSpeETqVLQqfSqXRJOFE5ScKbijVKsUYp1igXH6bSJaFT+SaVE5WTJJyodEn4pmKNUqxRijVK/MGLktCpdEk4UemScIdKl4QTlS4JncpJEjqVkyR0Km8q1ijFGqVYo8Qf/GFJ+CaVO5LQqXxSsUYp1ijFGiX+4IEkfJPKSRI6lZMkdCpdEk5UuiR0Kl0SOpU3FWuUYo1SrFEuXqbypiScJKFTOUnCSRJOVE5UuiR0Kl0SOpUnijVKsUYp1igXH5aEO1TelIROpUtCp3KShE6lS8IdKm8q1ijFGqVYo1wMp/IvKdYoxRqlWKNcDJOEO1S6JHQqnUqXhN+kWKMUa5RijXLxYSqfpNIloVO5Q+UkCScqXRK6JHQqbyrWKMUapVijXLwsCd+UhDuS0Kl0SehUOpUuCXeofFKxRinWKMUaJf5gjVGsUYo1SrFGKdYoxRqlWKMUa5RijVKsUYo1SrFGKdYoxRqlWKMUa5T/ALpEAfQP0k...

But it doesn't work at all.

I understand now. Instead of using the above string, I use this

iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAYAAABUmhYnAAAAAklEQVR4AewaftIAAAKkSURBVO3BQW7sWAwEwSxC979yjpdcPUCQusfmZ0T8wRqjWKMUa5RijVKsUYo1SrFGKdYoxRqlWKMUa5RijVKsUYo1SrFGKdYoFw8l4ZtUvikJ36TyRLFGKdYoxRrl4mUqb0rCHUk4UXlC5U1JeFOxRinWKMUa5eLDknCHyh1J+D8l4Q6VTyrWKMUapVijXAyj0iXhJAmdyl9WrFGKNUqxRrkYJgmdSpeEyYo1SrFGKdYoFx+m8k0qXRI6lS4JT6j8JsUapVijFGuUi5clYbIk/GbFGqVYoxRrlIuHVH4zlS4Jd6j8JcUapVijFGuUi4eS0Kl0SXiTSqdykoROpUvCSRLepPJJxRqlWKMUa5SLh1ROVN6UhG9S6ZLQqXRJOEnCicoTxRqlWKMUa5SLh5LQqXRJ+CSVLgmdSpeETqVLQqfSqXRJOFE5ScKbijVKsUYp1igXH6bSJaFT+SaVE5WTJJyodEn4pmKNUqxRijVK/MGLktCpdEk4UemScIdKl4QTlS4JncpJEjqVkyR0Km8q1ijFGqVYo8Qf/GFJ+CaVO5LQqXxSsUYp1ijFGiX+4IEkfJPKSRI6lZMkdCpdEk5UuiR0Kl0SOpU3FWuUYo1SrFEuXqbypiScJKFTOUnCSRJOVE5UuiR0Kl0SOpUnijVKsUYp1igXH5aEO1TelIROpUtCp3KShE6lS8IdKm8q1ijFGqVYo1wMp/IvKdYoxRqlWKNcDJOEO1S6JHQqnUqXhN+kWKMUa5RijXLxYSqfpNIloVO5Q+UkCScqXRK6JHQqbyrWKMUapVijXLwsCd+UhDuS0Kl0SehUOpUuCXeofFKxRinWKMUaJf5gjVGsUYo1SrFGKdYoxRqlWKMUa5RijVKsUYo1SrFGKdYoxRqlWKMUa5T/ALpEAfQP0k==

I just realize that, my string only works if input of QR Code module is number. If input is string then doesn't work. :disappointed_relieved:

According to the readme ...

Input
msg.qrcodeinput Custom string, it will be used instead of editor configuration. e.g.:

msg.qrcodeinput = 'mailto:someone@yoursite.com';
creates QRcode with action text for sending email to a specific address.

So clearly it is supposed to work with strings. Try that example ^

Sorry for the misunderstanding. After trying some examples, I found that, the case, which I used, was very simple and it only work the this case. Whenever I try number or string, it doesn't work.

For the second option, my question is, how to build a html email?

I'm pretty sure it's explained in the built in help or it links off to documentation (not at computer so can't look for you)

Also. Search this forum for html email

Just wanna share my solution. It works perfectly.

[{"id":"9c5ed362.12c938","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a52a042c.1cb6a8","type":"qrcode-generator","z":"9c5ed362.12c938","name":"","qrtype":"text2qr","text2qrText":"","ssid":"","hiddenssid":false,"wifitype":"","phonenum":"","smsphonenum":"","smstext":"","mailto":"","mailsubject":"","mailbody":"","latitude":"","longitude":"","colorlight":"#ffffff","colordark":"#000000","printstatus":false,"x":371,"y":347,"wires":[["80566094.f15978","b2bb01df.2d54f8"]]},{"id":"80566094.f15978","type":"debug","z":"9c5ed362.12c938","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":411,"y":287,"wires":[]},{"id":"c34f5471.71aa2","type":"e-mail","z":"9c5ed362.12c938","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"xxx@gmail.com","dname":"Send email","x":1111,"y":307,"wires":[]},{"id":"8f40c59c.13ee88","type":"change","z":"9c5ed362.12c938","name":"Flow 3 : Setup mail content","rules":[{"t":"set","p":"cid","pt":"msg","to":"","tot":"date"},{"t":"set","p":"attachments","pt":"msg","to":"[{\t    \"filename\": 'image_' & $replace($now(),\":\",\"_\") & '.jpg', \t    \"content\": $$.payload,\t    \"cid\": \"\" & cid & \"\"\t}]","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"See attached image","tot":"str"},{"t":"set","p":"html","pt":"msg","to":"<img src=\"{{msg.payload}}\">","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":881,"y":347,"wires":[["72c63841.67171","c34f5471.71aa2"]]},{"id":"72c63841.67171","type":"debug","z":"9c5ed362.12c938","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1091,"y":387,"wires":[]},{"id":"f0b540f2.1fa508","type":"function","z":"9c5ed362.12c938","name":"","func":"msg.qrcodeinput = msg.payload;\ndelete msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":201,"y":347,"wires":[["a52a042c.1cb6a8"]]},{"id":"5c6e5a08.29a92c","type":"debug","z":"9c5ed362.12c938","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":591,"y":407,"wires":[]},{"id":"b2bb01df.2d54f8","type":"function","z":"9c5ed362.12c938","name":"","func":"msg.payload = Buffer.from(msg.payload.substr(22), 'base64');\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":601,"y":347,"wires":[["5c6e5a08.29a92c","8f40c59c.13ee88"]]},{"id":"b5624255.bf4898","type":"inject","z":"9c5ed362.12c938","name":"Sign and Validate","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAYAAABUmhYnAAAAAklEQVR4AewaftIAAAKtSURBVO3BQa7jSAwFwXyE7n/lHC+5KkCQbPxhMyJ+sMYo1ijFGqVYoxRrlGKNUqxRijVKsUYp1ijFGqVYoxRrlGKNUqxRijXKxUNJ+CWVO5LQqdyRhF9SeaJYoxRrlGKNcvEylTcl4Y4kdCpvUnlTEt5UrFGKNUqxRrn4siTcoXJHEjqVkyScqNyRhDtUvqlYoxRrlGKNcjFMEv5lxRqlWKMUa5SLYVS6JHQqXRImKdYoxRqlWKNcfJnKX5KETuUJlb+kWKMUa5RijXLxsiT8ZSpdEjqVkyT8ZcUapVijFGuU+MH/WBLuUJmsWKMUa5RijRI/eCAJnUqXhDep3JGEE5WTJLxJ5ZuKNUqxRinWKPGDFyXhDpVfSsITKidJ6FS6JJyoPFGsUYo1SrFGuXiZyh1JeJNKl4ROpUtCp9IloUtCp3KHSpeENxVrlGKNUqxRLh5Kwh0qnUqXhE7lJAl3JOEkCScqdyThl4o1SrFGKdYoFw+pdEk4ScKJSpeETuUJlS4JncpJEjqVTuUkCZ3Km4o1SrFGKdYoFy9TeZPKHUnoVH4pCZ1Kp/JNxRqlWKMUa5T4wQNJ+CWVJ5LQqXRJ6FROktCpnCThROWJYo1SrFGKNcrFy1TelISTJHQqJyonKidJuCMJnUqXhDcVa5RijVKsUS6+LAl3qDyRhDtUuiR0Kp1Kl4QuCXeovKlYoxRrlGKNcjGMykkSuiScJOFEpUtCp/JLxRqlWKMUa5SLf4xKl4ROpUvCE0noVL6pWKMUa5RijXLxZSrfpNIloVPpknCShG9KQqfypmKNUqxRijXKxcuS8EtJ6FROVLokdConSThR6ZLQqXxTsUYp1ijFGiV+sMYo1ijFGqVYoxRrlGKNUqxRijVKsUYp1ijFGqVYoxRrlGKNUqxRij...","payloadType":"str","x":100,"y":240,"wires":[["f0b540f2.1fa508"]]}]

Admin Edit: removed real email address from flow

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.