Skip to content

Sending emails with attachment don't work with option. #764

@Pascaltib

Description

@Pascaltib

Describe the Bug

When an email has an attachment, and you use react it will send a blank email with only the attachment.

Image

This will NOT work and send a blank email with only the attachment:

             const { error } = await resend.emails.send({
				from: 'Know Thyself 360° <[email protected]>',
				to: [recipient.email],
				subject,
				react: ShareReport({
					name: recipient.name,
					message
				}),
				attachments: [
					{
						content: pdfBase64,
						filename: `${reportOwnerName} - 360 Feedback Report.pdf`
					}
				]
			})

This will work:

            const emailHtml = await render(
				ShareReport({
					name: recipient.name,
					message
				})
			)

            const { error } = await resend.emails.send({
				from: 'Know Thyself 360° <[email protected]>',
				to: [recipient.email],
				subject,
				html: emailHtml,
				attachments: [
					{
						content: pdfBase64,
						filename: `${reportOwnerName} - 360 Feedback Report.pdf`
					}
				]
			})

Link to the code that reproduces this issue

See code above. Going from react to html fixes the issue but is clearly a bug.

To Reproduce

Described above

Expected Behavior

Should work when using react:

What's your node version? (if relevant)

v22.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions