Skip to content

Commit 180217e

Browse files
committed
update readme
1 parent 7b4e408 commit 180217e

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed

README.md

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,51 @@ You can send a single email by creating a `ResendEmail` object and retrieving th
4141
~~~~swift
4242
import Resend
4343

44-
let email: ResendEmail = .init(
45-
from: .init(email: "hadi@example.com", name: "Hadi"),
46-
to: ["hadi@domain.com"],
47-
subject: "running xctest",
48-
replyTo: [
49-
"hadi@example.com",
50-
"manager@example.com"
51-
],
52-
text: "sending email from XCTest suit",
53-
headers: [
54-
.init(name: "X-Entity-Ref-ID", value: "234H3-44"),
55-
.init(name: "X-Entity-Dep-ID", value: "SALE-03"),
56-
],
57-
attachments: [
58-
.init(content: .init(data: .init(contentsOf: .init(filePath: "path/to/a/file"))),
59-
filename: "sales.xlsx")
60-
],
61-
tags: [
62-
.init(name: "priority", value: "medium"),
63-
.init(name: "department", value: "sales")
64-
]
65-
)
44+
let email = ResendEmail(
45+
from: .init(email: "hadi@example.com", name: "Hadi"),
46+
to: ["hadi@domain.com"],
47+
subject: "running xctest",
48+
replyTo: [
49+
"hadi@example.com",
50+
"manager@example.com"
51+
],
52+
text: "sending email via Resend API",
53+
headers: [
54+
.init(name: "X-Entity-Ref-ID", value: "234H3-44"),
55+
.init(name: "X-Entity-Dep-ID", value: "SALE-03"),
56+
],
57+
attachments: [
58+
.init(content: .init(data: .init(contentsOf: .init(filePath: "path/to/a/file"))),
59+
filename: "sales.xlsx")
60+
],
61+
tags: [
62+
.init(name: "priority", value: "medium"),
63+
.init(name: "department", value: "sales")
64+
]
65+
)
66+
~~~~
67+
68+
Emails can be scheduled to be sent later. The date should be a `Date` object or a string in natural language (e.g.: in 1 min)
6669

70+
~~~~swift
71+
let email = ResendEmail(
72+
to: ["hadi@domain.com"],
73+
subject: "sending scheduled email",
74+
scheduledAt: "in an hour",
75+
text: "sending email via Resend API",
76+
)
77+
78+
let email = ResendEmail(
79+
to: ["hadi@domain.com"],
80+
subject: "sending scheduled email",
81+
scheduledAt: .date(Date(timeIntervalSinceNow: 60\*60)),
82+
text: "sending email via Resend API",
83+
)
84+
~~~~
85+
86+
Now the email can be sent using resend client
87+
88+
~~~~swift
6789
let id = try await resendClient.emails.send(email)
6890
~~~~
6991
`ResendEmail` supports both `text` and `html` content.

0 commit comments

Comments
 (0)