Cancel
Cancels a scheduled email by ID.
func (s *EmailsSvcImpl) Cancel(emailId string) (*CancelScheduledEmailResponse, error)
Parameters
The unique identifier of the scheduled email to cancel.
Returns
response
*CancelScheduledEmailResponse
Show CancelScheduledEmailResponse fields
The unique identifier of the canceled email.
The object type (“email”).
Example
package main
import (
"fmt"
"github.com/resend/resend-go/v3"
)
func main() {
client := resend.NewClient("re_123456789")
canceled, err := client.Emails.Cancel("4ef9a417-02e9-4d39-ad75-9611e0fcc33c")
if err != nil {
panic(err)
}
fmt.Printf("Canceled email: %s\n", canceled.Id)
}
CancelWithContext
Cancels a scheduled email by ID with context.
func (s *EmailsSvcImpl) CancelWithContext(ctx context.Context, emailId string) (*CancelScheduledEmailResponse, error)
Parameters
The unique identifier of the scheduled email to cancel.
Returns
response
*CancelScheduledEmailResponse
See Cancel for response field details.
Example
package main
import (
"context"
"fmt"
"github.com/resend/resend-go/v3"
)
func main() {
ctx := context.Background()
client := resend.NewClient("re_123456789")
// First, schedule an email
params := &resend.SendEmailRequest{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Scheduled Email",
Text: "This email will be sent later",
ScheduledAt: "2024-09-05T11:52:01.858Z",
}
sent, err := client.Emails.SendWithContext(ctx, params)
if err != nil {
panic(err)
}
// Cancel the scheduled email
canceled, err := client.Emails.CancelWithContext(ctx, sent.Id)
if err != nil {
panic(err)
}
fmt.Printf("Canceled email: %s\n", canceled.Id)
}