Aparna Mishra
Aparna Mishra

Reputation: 9

How to open Mail box and in body how to add my project UI with its styles on button click?

I have a requirement where on button click i need to open a mail box of default browser and also want to add my UI grid with its styles in the body content on single button click. but by using mail to i can only add the text without its style.

Upvotes: 0

Views: 97

Answers (1)

Bruno Kawka
Bruno Kawka

Reputation: 356

To create an element in Angular that opens the mailto URI and has an onClick handler calling the handleMailClick callback, you must define the handleMailClick method in your Angular component. Use Angular's template syntax to create the element with the mailto link and bind the click event to the handleMailClick method.

First, define the handleMailClick method in your component class:

import { Component } from '@angular/core';

@Component({
  selector: 'app-mail',
  templateUrl: './mail.component.html',
  styleUrls: ['./mail.component.css']
})
export class MailComponent {

  handleMailClick(event: Event): void {
    event.preventDefault();
    console.log('Mail link clicked');
    // Your logic here
  }
}

Next, create the element in the component's template and bind the click event to the handleMailClick method:

<a href="mailto:[email protected]" (click)="handleMailClick($event)">Send Email</a>

By following these steps, clicking the link will trigger the handleMailClick method, allowing you to add any custom logic you need when the link is clicked, and opening the default mail client.

Upvotes: 1

Related Questions