Skip to content

Delete sent mail

Call DeleteSentMailAsync() to delete sent mail. Use sent mail deletion to clean up the sending history or to hide recalled mail in the mailbox UI.

1. Check the deletion target and identifier

To delete sent mail, use the MailId you saved when sending it. It is a different value from the MailRecipientId used to delete received mail, so be careful not to confuse them. To show the latest status on the app screen, run Get sent mail again with the same MailId before deletion to check whether the mail has been recalled and whether it has expired. When you delete sent mail, it is excluded from the sent mail list and from detail retrieval.

Recalled mail

Recalled mail is mail whose Data.MailStatus in the Get sent mail details response is Revoked. Recalled sent mail is automatically and permanently deleted (HARD DELETE) after 90 days, even if you do not call the delete method separately.

Expired mail

Expired sent mail is also automatically and permanently deleted (HARD DELETE) after 90 days, even if you do not call the delete method separately. Recalled sent mail and expired sent mail remain in the Get the sent mail list results so that you can check the sending history. To exclude them from the list, you must call the delete method, and deleted sent mail no longer appears in later list and detail retrieval results.

2. Delete sent mail

Method

DeleteSentMailAsync

The deletion result of DeleteSentMailAsync() is delivered as the returned object. On success, the deleted MailId and the deletion time are returned together.

Deletion lifecycle

When you call the delete method, the sent mail first switches to a soft delete (SOFT DELETE) state so that it no longer appears in the mailbox UI. Data marked as deleted is kept according to the server retention policy and then automatically and permanently deleted (HARD DELETE) after 90 days.

Call parameters

Field name Type Required Description
request DeleteSentMailRequest Required Request that specifies the sent mail to delete
context ApiCallContext? Optional Per-call settings object. If omitted, the default values are used.

DeleteSentMailRequest

Field name Type Required Description
MailId string Required Identifier of the sent mail to delete

Call example

See the example below and the response status for the success result of MailboxDeleteSentMailResult and the domain-specific results (Outcome) of this method. For the result model and handling principles of common failures (Failure) returned when the request cannot be performed, see Common error handling.

using Hive.Axyl.Mailbox;
using Hive.Axyl.Core;

IMailboxService mailbox = HiveCore.Resolve<IMailboxService>();

var result = await mailbox.DeleteSentMailAsync(new DeleteSentMailRequest {
    MailId = storedMailId,
});

switch (result)
{
    case MailboxDeleteSentMailResult.Success success:
        DeletedSentMailResponseData data = success.Data;
        Debug.Log($"Sent mail deleted: {data.MailId} ({data.DeletedAt})");
        break;

    case MailboxDeleteSentMailResult.Failure failure:
        HiveError err = failure.Problem;
        Debug.LogError($"[{err.Code}] {err.Message} (trace: {err.TraceId})");
        break;

    default:
        Debug.LogWarning($"Unhandled result: {result.GetType().Name}");
        break;
}

Response data

On success, the result is contained in Data (DeletedSentMailResponseData) of MailboxDeleteSentMailResult.Success.

Both fields are declared with types that can hold null, so check whether a value is null before you show it on the screen or pass it to the next call.

Field name Type Required Description
Data.MailId string? Optional Identifier of the deleted sent mail
Data.DeletedAt DateTimeOffset? Optional Time when the sent mail was deleted

Response example

// success.Data (DeletedSentMailResponseData)
string? mailId = success.Data.MailId;
DateTimeOffset? deletedAt = success.Data.DeletedAt;

Response status

The returned object MailboxDeleteSentMailResult branches into one of the cases below. We recommend handling it with a switch statement.

Response case Description App client handling
Success Sent mail deletion succeeded. Remove it from the sent mail list and details
Failure Common Failure. See Common error handling. Handle according to the common error handling criteria
UnknownOutcome A new result that this SDK version does not recognize. Treat it as a failure and record the result code

3. Apply the deletion result and mail status

When deletion succeeds, remove the sent mail from the sent mail list in the mailbox UI. If you needed to check the recall status or detailed status again before deletion, see Get sent mail. If you need the recall feature, also see Recall mail.