Documentation
Client SDK
List mails in trash

Get mails from trash

The secrecyClient.mail.deletedMails method is used to get all the mails that have been soft deleted. It accepts an argument of type DeletedMailType that can only have one of two string values: sent or received.

The mailType property is equal to : sent | received

Get sent deleted mails

The secrecyClient.mail.deletedMails is a method that retrieves deleted sent mails using the secrecyClient. It accepts a parameter mailType of type DeletedMailType, which is a union type that can either be sent or received.

mail-trash.ts
type DeletedMailType = 'sent' | 'received';
 
const getSentMailsFromTrash = async (
  mailType: DeletedMailType
): Promise<Mail[] | null> => {
  // First we need to check if the secrecyClient is available
  if (!secrecyClient) {
    return null;
  }
 
  try {
    // retrieve the deleted sent mails
    const deletedSentMails = await secrecyClient.mail.deletedMails({
      mailType: 'sent',
    });
    return deletedSentMails;
  } catch (error) {
    console.error(error);
    return null;
  }
};

Get received deleted mails

The secrecyClient.mail.deletedMails is a method that retrieves deleted received mails using the secrecyClient. It accepts a parameter mailType of type DeletedMailType, which is a union type that can either be sent or received.

mail-trash.ts
type DeletedMailType = 'sent' | 'received';
 
const getSentMailsFromTrash = async (
  mailType: DeletedMailType
): Promise<Mail[] | null> => {
  // First we need to check if the secrecyClient is available
  if (!secrecyClient) {
    return null;
  }
 
  try {
    // retrieve the deleted received mails
    const deletedReceivedMails = await secrecyClient.mail.deletedMails({
      mailType: 'received',
    });
    return deletedReceivedMails;
  } catch (error) {
    console.error(error);
    return null;
  }
};