@@ -41,29 +41,51 @@ You can send a single email by creating a `ResendEmail` object and retrieving th
41
41
~~~~ swift
42
42
import Resend
43
43
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)
66
69
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
67
89
let id = try await resendClient.emails .send (email)
68
90
~~~~
69
91
` ResendEmail ` supports both ` text ` and ` html ` content.
0 commit comments