• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / Angular / Mailto with subject as Service

Mailto with subject as Service

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

@Injectable({
providedIn: 'root'
})
export class MailtoService {
private readonly _email = 'hellodata@trendency.hu';
private readonly _subject = 'Ajánlatot kérek';

public openMailto(body?: string): void {
const mailtoUrl = `mailto:${this._email}?subject=${encodeURIComponent(this._subject)}${
body ? `&body=${encodeURIComponent(body)}` : ''
}`;

window.location.href = mailtoUrl;
}
}
private readonly _mailto = inject(MailtoService);

public mailtoWithSubject(): void {
this._mailto.openMailto();
}
<app-button [label]="'HEADER.LABEL' | transloco" (clickEvent)="mailtoWithSubject()" />

Filed Under: Angular

About Gabor Flamich

I'm a web developer and designer based in Budapest, Hungary. In recent years, I've documented hundreds of solutions I came across during development. This site is an archive for useful code snippets on WordPress, Genesis Framework and WooCommerce. If You have any questions related to WordPress development, get in touch!

Primary Sidebar

  • angular.io
© 2026 WP Flames - All Right Reserved