core.medplumclient.sendemail
Home > @medplum/core > MedplumClient > sendEmail
MedplumClient.sendEmail() method
Sends an email using the Medplum Email API.
Builds the email using nodemailer MailComposer.
Examples:
Signature:
sendEmail(email: MailOptions, options?: RequestInit): Promise<OperationOutcome>;
Parameters
Parameter | Type | Description |
---|---|---|
MailOptions | The MailComposer options. | |
options | RequestInit | (Optional) Optional fetch options. |
Returns:
Promise<OperationOutcome>
Promise to the operation outcome.
Example 1
Send a simple text email:
await medplum.sendEmail({
to: 'alice@example.com',
cc: 'bob@example.com',
subject: 'Hello',
text: 'Hello Alice',
});
Example 2
Send an email with a Binary
attachment:
await medplum.sendEmail({
to: 'alice@example.com',
subject: 'Email with attachment',
text: 'See the attached report',
attachments: [{
filename: 'report.pdf',
path: "Binary/" + binary.id
}]
});
See options here: https://nodemailer.com/extras/mailcomposer/