ARTICLE AD BOX
I am trying to send an image in the body of an Outlook email using Angular. But it is not working. Is this possible? If anyone knows please help to find the solution.
app.component.ts:
import { Component, VERSION, OnInit } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], }) export class AppComponent implements OnInit { name = 'Angular ' + VERSION.major; base64 = 'iVBORw0KGgoAAAANSUhEUgAAAPgAAAD4CAYAAADB0SsLAAAAAXNSR0IArs4c6Q....'; qrimg = `data:image/png;base64,${this.base64}`; ngOnInit(): void {} sendEmailWithEmbeddedImage() { const base64Image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...'; const emailBody = ` <html> <body> <p>Hello,</p> <p>Here is your embedded image:</p> <img src="${this.qrimg}" alt="Embedded Image" width="300"> <p>Best regards,</p> </body> </html> `; const mailtoLink = `mailto:?subject=Test Email&body=${encodeURIComponent( emailBody )}`; window.location.href = mailtoLink; } }app.component.html:
<button (click)="sendEmailWithEmbeddedImage()"> sendEmailWithEmbeddedImage </button>Demo: https://stackblitz.com/edit/angular-ivy-2wa7poce?file=src%2Fapp%2Fapp.component.ts
