Generate QR Code and send it by Email (As embedded image / attachment )

I want to do the following:
Based on some field values in a table, I want to generate a QR Code and send it as email. I ran into the following problems

  1. Data Type QR Code is available only in Grid.
  2. So using grid, I generated the QR Code and tried to see it or send it by email, but it just sends the TEXT (text code and not image)
  3. Next I used the PHPQRCode Library to generate the QR Code. But then I am not able to get the generated code image stored into a variable. So, I next stored it into a file
  4. Next, I tried using the sc_mail_send to send the above generated ffile as Attachment. The application crashed with SWIFT exception error
    But without attachement mail goes through. I am referring the file with full path and still the same issue.
    My development environment is Windows 11. So I also took care of the addslashes() etc with no luck.
    Can somebody help

$mail_smtp_server = ‘smtp.hostinger.com’; // SMTP server name or IP address
$mail_smtp_user = ‘iusername’; // SMTP user name
$mail_smtp_pass = ‘password’; // SMTP password
$mail_from = ‘info@ccc.in’; // From email
$mail_to = {er_ev_email_address}; // ‘sriraminfotec@gmail.com’; // To email
$mail_subject = ‘Test message’; // Message subject
$mail_message = 'This is a test message. ’ .{uniqueqrcode}; // Message body
$mail_attachment = $completePath;
$mail_format = ‘T’; // Message format: (T)ext or (H)tml
$mail_copies = ‘’; // List of the emails that will recieve the message
$mail_tp_copies = ‘’; // Type copies: BCC (Hiden copies) or CCC (Regular copies)
$mail_port = ‘465’; // Server port
$mail_tp_connection = ‘S’; // Connection security (S) or (N)

// Send email";
sc_mail_send($mail_smtp_server,
$mail_smtp_user,
$mail_smtp_pass,
$mail_from,
$mail_to,
$mail_subject,
$mail_message,
$mail_attachment,
$mail_format,
$mail_copies,
$mail_tp_copies,
$mail_port,
$mail_tp_connection);
I have checked the $completePath using echo command. I have also seen the QR CODE Image ile getting created in the folder.
Any help appreciated