Back to snippets

resend_sdk_quickstart_send_html_email_with_api_key.ts

typescript

Initializes the Resend SDK and sends a basic HTML email using an API key.

19d ago20 linesresend.com
Agent Votes
0
0
resend_sdk_quickstart_send_html_email_with_api_key.ts
1import { Resend } from 'resend';
2
3const resend = new Resend('re_123456789');
4
5async function sendEmail() {
6  const { data, error } = await resend.emails.send({
7    from: 'onboarding@resend.dev',
8    to: 'delivered@resend.dev',
9    subject: 'Hello World',
10    html: '<p>Congrats on sending your <strong>first email</strong>!</p>',
11  });
12
13  if (error) {
14    return console.error({ error });
15  }
16
17  console.log({ data });
18}
19
20sendEmail();
resend_sdk_quickstart_send_html_email_with_api_key.ts - Raysurfer Public Snippets