LogoLogo
  • Platform Overview
  • 🗺️Guides
    • Getting Started
    • Users
      • Integrate the User SDK
      • Registration
      • Authentication
      • SDK Releases
      • API Reference
    • Entitlements
      • Administrative API
        • Integrating the Administrative API
        • Entitlement Definitions
        • Managing Entitlements Sets
        • Managing Entitlements Sequences
        • Managing User Entitlements
        • API Schema
      • End-user API
        • Integrate the Entitlements SDK
        • Redeeming Entitlements
        • Retrieving Entitlements
        • SDK Releases
        • API Reference
    • Sudos
      • Integrate the Sudo Profiles SDK
      • Sudo Entitlements
      • Manage Sudos
      • SDK Releases
      • API Reference
    • Telephony
      • Integrate the Telephony SDK
      • Manage Phone Numbers
      • Text Messaging
      • Voice Calling
      • Telephony Simulator
      • SDK Releases
      • API Reference
    • Email
      • Integrate the Email SDK
      • Email Entitlements
      • Manage Email Addresses
      • Sending & Receiving Email
      • Manage Email Folders
      • Draft Email Messages
      • Schedule Send
      • Manage Email Address Blocklists
      • Email Address Public Information
      • Pagination
      • Caching
      • Configuration Data
      • Email Notifications
      • SDK Releases
      • API Reference
    • Decentralized Identity
      • Edge Agent
        • Relay SDK
          • Integrate the Relay SDK
          • Relay Entitlements
          • Manage Relay Postboxes
          • Manage Relay Messages
          • Receiving Messages
          • SDK Releases
        • Edge Agent SDK
          • Integrate the Edge Agent SDK
          • Agent Management
          • Manage Wallets
          • Establishing Connections
          • Manage Connections
          • Messaging
          • Manage DIDs
          • Accepting New Credentials
          • Manage Credentials
          • Present Credentials for Verification
          • Utilize Alternative Cryptography Providers
          • SDK Releases
          • Standards and Protocols
      • Cloud Agent
        • Cloud Agent Admin API
          • Integrate the Cloud Agent Admin API
          • Aries Interop Profile (AIP)
            • Connection Exchanges
            • Credential Exchanges
            • Proof Exchanges
          • Connections
          • Basic Messages
          • Credentials
            • Anoncreds Credentials
              • Schemas
              • Credential Definitions
            • W3C Credentials
          • Audit Logs
          • API Schema
          • Error Codes
          • Standards and Protocols
    • Virtual Cards
      • Integrate the Virtual Cards SDK
      • Virtual Cards Entitlements
      • Virtual Cards Transaction Velocity Constraints
      • Key Management
      • Manage Funding Sources
      • Manage Virtual Cards
      • Manage Transactions
      • Configuration Data
      • Pagination
      • Caching
      • SDK Releases
      • API Reference
    • Virtual Cards Simulator
      • Integrate the Virtual Cards Simulator SDK
      • Simulate Authorizations
      • Simulate Debits
      • Simulate Refunds
      • Simulate Reversals
      • Merchants and Currencies
      • SDK Releases
      • API Reference
    • Virtual Private Network
      • Integrate the VPN SDK
      • VPN Entitlements
      • Manage Servers
      • Manage Connection
      • Observe VPN Related Events
      • SDK Releases
      • API Reference
      • Frequently Asked Questions
    • Secure ID Verification
      • Integrate the Secure ID Verification SDK
      • List Supported Countries
      • Verify an Identity
      • Check Secure ID Verification Status
      • Use the Secure ID Verification Simulator
      • SDK Releases
      • API Reference
    • Password Manager
      • Integrate the Password Manager SDK
      • Accessing the Password Manager
      • Managing Password Vaults
      • Managing Password Vault Items
      • Vault Import and Export
      • Password Utilities
      • Password Manager Entitlements
      • Password Vault Security
      • SDK Releases
      • API Reference
    • Ad/Tracker Blocker
      • Integrate the Ad/Tracker Blocker SDK
      • Manage Rulesets
      • Blocking Ads and Trackers
      • Manage Exceptions
      • SDK Releases
      • API Reference
    • Site Reputation
      • Integrate the Site Reputation SDK
      • Use the Site Reputation SDK
      • SDK Releases
      • API Reference
  • 💡Concepts
    • Sudo Digital Identities
  • 🧱Development
    • Versioning
  • 🏢Administration
    • Admin Console Roles
  • ❓Get Help
    • Request a Demo
    • Report an Issue
Powered by GitBook
On this page
  • Scheduling a Draft Message
  • Cancelling a Scheduled Draft Message
  • Listing Scheduled Draft Messages
  1. Guides
  2. Email

Schedule Send

Schedule a message to be sent at a specified date and time in the future.

The Email SDK supports scheduling draft email messages to be sent at a specified time in the future. The Email Service will periodically check for messages that have been scheduled whose sendAt times have passed and will send them as normal. Your runtime instance can be configured to specify how often you want this check to occur. More frequent checks will increase the chances that the messages will be sent as close to the specified time as possible. If a message fails to send for any reason, it may also be retried a configurable number of times.

Scheduling a Draft Message

To schedule a draft message to be sent in the future, call the scheduleSendDraftMessage method. This method takes in the id of the draft message to schedule, the emailAddressId of the email address that owns the draft message and the sendAt timestamp of when to send the message. The call will return a record of the scheduled message with useful information including the sendAt timestamp, the updatedAt timestamp and the state of the scheduled message. There are four states that the scheduled message may be in:

State
Meaning

SCHEDULED

The message has been scheduled and will be sent once the sendAt time has passed.

FAILED

The message failed to send after the sendAt passed.

SENT

The message has successfully been sent. It should appear in the SENT folder of the user's email address.

CANCELLED

The message was cancelled and will not be sent.

// Obtain the draftId and emailAddressId however makes sense for your application
const id = draft.id
const emailAddressId = senderEmailAddress.id
const sendAt = DateTime.now().plus({ day: 1 }).toJSDate() // Adjust this to the required time in the future
try {
    const scheduledDraftMessage = await emailClient.scheduleSendDraftMessage({
        id,
        emailAddressId,
        sendAt,
    })
} catch (e) {
    // Handle/notify user of errors
}
// Obtain the draftId and emailAddressId however makes sense for your application
let id = draft.id
let emailAddressId = senderEmailAddress.id
let sendAt = Date().addingTimeInterval(+86400) // Adjust this to the required time in the future
let input = ScheduleSendDraftMessageInput(
    id: id,
    emailAddressId: emailAddressId,
    sendAt: sendAt
)
do {
    let scheduledDraftMessage = try await emailClient.scheduleSendDraftMessage(withInput: input)
} catch {
    // Handle/notify user of errors
}
// Obtain the draftId and emailAddressId however makes sense for your application
val id = draft.id
val emailAddressId = senderEmailAddress.id
val sendAt = Date(Date().time + Duration.ofDays(1).toMillis()) // Adjust this to the required time in the future
launch {
    try {
        val input = ScheduleSendDraftMessageInput(
            id,
            emailAddressId,
            sendAt,
        )
        val scheduledDraftMessage = withContext(Dispatchers.IO) {
            emailClient.scheduleSendDraftMessage(input)
        }
    } catch (e: EmailMessageException) {
        // Handle/notify user of exception
    }
}

Cancelling a Scheduled Draft Message

A previously scheduled draft message can be cancelled at any time before it's specified sendAt time by calling the cancelScheduledDraftMessage method. This method takes the draft message id and the emailAddressId of the email address that owns the draft and will return the draft id on successful cancellation.

// Obtain the draftId and emailAddressId however makes sense for your application
const id = draft.id
const emailAddressId = senderEmailAddress.id
try {
    const cancelledScheduledDraftId = await client.cancellScheduledDraftMessage({
        id,
        emailAddressId,
    })
} catch (e) {
    // Handle/notify user of errors
}
// Obtain the draftId and emailAddressId however makes sense for your application
let id = draft.id
let emailAddressId = senderEmailAddress.id
let input = CancelScheduledDraftMessageInput(
    id: id,
    emailAddressId: emailAddressId,
)
do {
    let cancelledScheduledDraftId = try await emailClient.cancelScheduledDraftMessage(withInput: input)
} catch {
    // Handle/notify user of errors
}
// Obtain the draftId and emailAddressId however makes sense for your application
val id = draft.id
val emailAddressId = senderEmailAddress.id
launch {
    try {
        val input = CancelScheduledDraftMessageInput(
            id,
            emailAddressId,
        )
        val cancelledScheduledDraftId = withContext(Dispatchers.IO) {
            emailClient.cancelScheduledDraftMessage(input)
        }
    } catch (e: EmailMessageException) {
        // Handle/notify user of exception
    }
}

Listing Scheduled Draft Messages

To retrieve a list of previously scheduled draft messages, call the listScheduledDraftMessagesForEmailAddressId method. This method takes the emailAddressId , an optional filters argument to filter your results and pagination arguments (See Pagination for details). It will return a list of Scheduled Draft Messages.

// Obtain the emailAddressId however makes sense for your application
const emailAddressId = senderEmailAddress.id
const filter: ScheduledDraftMessageFilterInput = {
    state: {
        notEqual: ScheduledDraftMessageState.CANCELLED,
    },
}
try {
    const listResult = await emailClient.listScheduledDraftMessagesForEmailAddressId({
        emailAddressId,
        filter,
    })
} catch (e) {
    // Handle/notify user of errors
}
// Obtain the emailAddressId however makes sense for your application
let emailAddressId = senderEmailAddress.id
let input = ListScheduledDraftMessagesForEmailAddressIdInput(
    emailAddressId: emailAddressId,
    limit: nil,
    nextToken: nil,
    filter: ScheduledDraftMessageFilter(
        state: ScheduledDraftMessageStateFilter.notEqual(.cancelled)
    )
)
do {
    let listResult = try await emailClient.listScheduledDraftMessagesForEmailAddressId(withInput: input)
} catch {
    // Handle/notify user of errors
}
// Obtain the draftId and emailAddressId however makes sense for your application
val emailAddressId = senderEmailAddress.id
launch {
    try {
        vval input = ListScheduledDraftMessagesForEmailAddressIdInput(
            emailAddressId,
            filter = ScheduledDraftMessageFilterInput(
                state = NotEqualStateFilter(
                    notEqual = ScheduledDraftMessageState.CANCELLED,
                ),
            ),
        )
        val listResult = withContext(Dispatchers.IO) {
            emailClient.listScheduledDraftMessagesForEmailAddressId(input)
        }
    } catch (e: EmailMessageException) {
        // Handle/notify user of exception
    }
}

The listScheduledDraftMessagesForEmailAddressId method currently supports filtering results by state. The above example would list all results where the state is not equal to CANCELLED , but there are other options as defined below:

Filter Option
Type
Meaning

equal

ScheduledDraftMessageState

Return only results that match the given state.

oneOf

Array<ScheduledDraftMessageState>

Return only results that match one of the given states.

notEqual

ScheduledDraftMessageState

Return only results that do not match the given state.

notOneOf

Array<ScheduledDraftMessageState>

Return only results that do not match any of the given states.

PreviousDraft Email MessagesNextManage Email Address Blocklists

Last updated 2 days ago

🗺️