Delete received mail
Call DeleteReceivedMailAsync() to delete received mail. Use received mail deletion when the user selects delete on the mailbox screen or when the app applies a policy for cleaning up expired mail.
1. Check the deletion target and identifier
To delete received mail, use MailRecipientId, the identifier of the received mail. It is a different value from the MailId used to delete sent mail, so you must pass the value exactly as you found it in the received mail details or the received mail list. To show the latest status on the app screen, run the Get received mail flow again before deletion to refresh the list and details.
Expired mail
By default, expired mail is automatically and permanently deleted (HARD DELETE) after 90 days, even if you do not call the delete method separately.
From the moment it expires, expired received mail is excluded from the results of Get the received mail list and Get received mail details, so you cannot determine whether it has expired by asking the server for its status again. Instead, have the app determine this itself by comparing the ExpiresAt value received in advance from the list retrieval with the current time. To immediately hide mail that expires while the mailbox screen is open, call the delete method with the MailRecipientId you already have.
Mail with attached items
Mail with attached items is also deleted with the delete method. However, Hive Axyl provides only the feature to mark the claim status of attached items. The app must implement every other feature that handles attached items, such as saving, storing, deleting, recalling, and claiming the actual attached items.
2. Delete received mail
DeleteReceivedMailAsync
The deletion result of DeleteReceivedMailAsync() is delivered as the returned object. On success, the deleted MailRecipientId, the original MailId, and the deletion time are returned together.
Deletion lifecycle
When you call the delete method, the received mail first switches to a soft delete (SOFT DELETE) state so that it no longer appears on the mailbox screen. 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 | DeleteReceivedMailRequest | Required | Request that specifies the received mail to delete |
context | ApiCallContext? | Optional | Per-call settings object. If omitted, the default values are used. |
DeleteReceivedMailRequest
| Field name | Type | Required | Description |
|---|---|---|---|
MailRecipientId | string | Required | Identifier of the received mail to delete. It is a different value from the MailId of sent mail. |
Call example
See the example below and the response status for the success result of MailboxDeleteReceivedMailResult 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.DeleteReceivedMailAsync(new DeleteReceivedMailRequest {
MailRecipientId = receivedMailId,
});
switch (result)
{
case MailboxDeleteReceivedMailResult.Success success:
DeletedReceivedMailResponseData data = success.Data;
Debug.Log($"Received mail deleted: {data.MailRecipientId} ({data.DeletedAt})");
break;
case MailboxDeleteReceivedMailResult.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 (DeletedReceivedMailResponseData) of MailboxDeleteReceivedMailResult.Success.
All three 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.MailRecipientId | string? | Optional | Identifier of the deleted received mail |
Data.MailId | string? | Optional | Identifier of the original sent mail linked to the deleted received mail |
Data.DeletedAt | DateTimeOffset? | Optional | Time when the received mail was deleted |
Response example
Response status
The returned object MailboxDeleteReceivedMailResult branches into one of the cases below. We recommend handling it with a switch statement.
| Response case | Description | App client handling |
|---|---|---|
Success | Received mail deletion succeeded. | Remove it from the mailbox list |
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
To also show, before deletion, whether the mail body was read or whether the attached items were claimed, check TextReadAt and AttachmentReadAt in Get received mail. If you need to apply the body read status or the attached item claim status, also see Mark mail as read.