Skip to content

Commit

Permalink
fix: Attachment examples (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha authored Aug 15, 2024
1 parent b895e9c commit d120c9f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions with-attachments-content/src/pages/api/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const send = async (req: NextApiRequest, res: NextApiResponse) => {
const { data } = await resend.emails.send({
from: 'Acme <[email protected]>',
to: ['[email protected]'],
subject: 'Email with attachment',
html: '<p>See attachment</p>',
subject: 'Receipt for your payment',
html: '<p>Thanks for the payment</p>',
attachments: [
{
content,
Expand Down
2 changes: 1 addition & 1 deletion with-attachments-content/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Index: React.FC = () => {
type="file"
name="file"
onChange={onAddFileAction}
accept="image/*"
accept="image/*,.pdf"
/>
<input type="submit" value="Send Email" />
</form>
Expand Down
Binary file removed with-attachments/public/static/invoice.pdf
Binary file not shown.
13 changes: 6 additions & 7 deletions with-attachments/src/pages/api/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ const send = async (req: NextApiRequest, res: NextApiResponse) => {
switch (method) {
case 'GET': {
const data = await resend.emails.send({
from: "Acme <[email protected]>",
to: ["[email protected]"],
subject: 'Receipt for Your Payment',
from: 'Acme <[email protected]>',
to: ['[email protected]'],
subject: 'Receipt for your payment',
html: '<p>Thanks for the payment</p>',
attachments: [
{
path: 'path/to/file/invoice.pdf',
filename: 'invoice.pdf',
path: 'https://resend.com/docs/sample/invoice.pdf',
filename: 'sample-invoice.pdf',
},
],
html: '<h1>Thanks for the payment</h1>',
text: 'Thanks for the payment',
});

return res.status(200).send({ data: data.id });
Expand Down

0 comments on commit d120c9f

Please sign in to comment.