I'm looking to send an email as a string to an API via a service using Angular 6.
I would like to have a separate HTML file that has the code for this email template. I would then like to pass in this HTML template to the service and then post it to the API. (Please note - I do not want to build the email template as a string. i want to build it in HTML and then convert it to string).
So say i have the following files:
email-template.html - holds the html email template code
email.service.ts - posts the email template code as string
How would I implement this?
Here is my service:
constructor(private httpClient: HttpClient) { }
send(recipient, email) { <=== need that 'email' perameter to be the email template.html as string
const object: Email = {
FromAddress: environment.noreplyEmailAddress,
ToAddress: recipient,
MessageBodyText: null,
MessageBodyHtml: email.template,
Subject: email.subject
};
return this.httpClient.post(`${this.url}/api/storeemail`, object, httpOptions);
}